Fork me on GitHub

@thheller I was looking into how to use shadow-cljs for creating chrome extension and came across this It seems to have been inactive since 2020. Has there been any new update since then?


I just haven't had time to test arround


supposedly eval is now forbidden so hot-reload and REPL no longer work


May be what I'm looking for since I'm not too well-versed when it comes to JS

Kovas Palunas18:05:06

Hey I'm working on a strange project that is targeting google apps script. I started out with this template:, but struggled a lot with getting a proper nrepl working with just lein and piggieback. I've since tried moving the project over to shadow-cljs, with pretty good success. Currently I can run a node repl successfully for development, but I'm still running into a couple problems: 1. When I try to push my Code.js file built with shadow-cljs to google apps script, it complains about a bunch of missing names that I think node provides to its scripts. Is there any way to tell shadow-cljs to build my script for node when i'm developing, and without these names when I'm deploying to google apps script (like lein cljsbuild once does in the linked repo)? I can just use lein cljsbuild once for deployment, but it feels weird to depend on two build tools like that. Maybe there's a simple solution? 2. Google Apps Script provides some names that are only available when running in Google Apps Script (not node). An example would be js/SpreadsheetApp ( When I try to run with these names uncommented in my shadow-cljs node environment I (rightly) get an error. What I would like to do is to have some kind of "if" branch in my code that uses e.g. js/SpreadsheetApp when running in google apps script, but a mock or fake that I define when running in node. Any tips for how to accomplish this? In other languages I feel like compiler macros would be the solution.


@kovas.palunas sorry but I know absolutely nothing about google apps script and the environment it runs in. :target :node-script assumes to be running in node, so that might explain errors. which errors would that be though? you didn't say.

Kovas Palunas19:05:46

The first part of the shadow-cljs generated code (for node) looks like this:

#!/usr/bin/env node
var shadow$provide = {};

var SHADOW_IMPORT_PATH = __dirname + '/.shadow-cljs/builds/autojournal/dev/out/cljs-runtime';
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/kovas/cljs_clamp/.shadow-cljs/builds/autojournal/dev/out/cljs-runtime"; }
global.$CLJS = global;
global.shadow$provide = {};
try {require('source-map-support').install();} catch (e) {console.warn('no "source-map-support" (run "npm install source-map-support --save-dev" to get it)');}

global.CLOSURE_NO_DEPS = true;
apps script complains when I try to run it because __dirname and global are not defined in it's environment

Kovas Palunas19:05:45

when i build with lein cljsbuild once, my file does not have those names referenced

Kovas Palunas19:05:39

i guess what i'm really looking for is a way to use shadow-cljs to build my final js file in the same way that cljsbuild does it

Kovas Palunas19:05:02

so i don't have parallel dependency files

Kovas Palunas19:05:41

BTW, my question 2 was answered in another channel, the solution I have is at I still am looking for a way to reference an env var or something in this macro that would let me know that shadow-cljs is building my code (vs lein, or shadow-cljs with different parameters if I find a solution to my question 1)

Kovas Palunas20:05:52

Maybe another way to phrase the question is: can shadow-cljs make a :target :browser build where all the code is in one self-contained file?