Hi! I have put together an app where we are building out new functionality in clojurescript, but also embedding an older javascript app inside. This has worked well and we have been able to work with the few constraints when building javascript sources. These sources are themselves first compiled from javascript, typescript, and vue files. The compilation is creating a sourcemap. It will be very beneficial to have these sourcemaps be used, so we can easily see the original sources (1000s of files) rather than the few that they are bundled down to before being compiled with shadow. I stumbled on https://clojureverse.org/t/using-original-js-source-maps/6469, which gave me some hope, but I see that these changes donโt seem to be in the current version of shadow anymore. Does anyone know of the current state of using sourcemaps for javascript sources going into shadow? Are there any pointers on how I can make this work?
input source maps kinda do not work. I tried a couple times getting them to work, but unfortunately that feature isn't very accessible inside the closure compiler. some behavior is hardcoded and doesn't match how shadow-cljs uses the actual closure compiler. adjusting that didn't seem feasible without modifications in the closure compiler itself, at least the last time I checked. It has been a while though. maybe you'd have more luck integrating the CLJS outputs in the JS build instead?
Ok. Iโll have to see if I can get it working the other direction sometime. Thank you for the reply and for sharing shadow with all of us!
When I have the sourcemaps as sibling files in the directory. I get a log message from shadow that it failed to find them (so it is trying ยฏ\(ใ)/ยฏ ), although, it appears that it is using a path that should successfully be found as a resource from the classpath. When I build the javascript with โinlineโ sourcemaps (`data:` urls), then it actually fails to compile with a the message no output for id: [:shadow.build.classpath/resource "file/that/exists.js"].
Thanks in advance for any help or pointers on the current state of things or constraints to making these work.
The logs when the sourcemaps are sibling files is the following:
[shadow:watch ] ------ WARNING #1 - -----------------------------------------------------------
[shadow:watch ] Resource:
[shadow:watch ] Failed to resolve sourcemap at file/that/exists.js.map: file/that/exists.js.map
[shadow:watch ] --------------------------------------------------------------------------------Hi, I found that npm package sqlite-async offers ES6 promises based wrapper to sqlite3 core driver that uses callbacks.
I included both in my package.json. In my repl, I am getting an error when I use (require ["sqlite-async":as mysqlite])
REPL Invoke Exception Error [ERR_REQUIRE_ESM]: require() of ES Module sqlite-async.js from shadow-cljs-express/[stdin] not supported.
; Instead change the require of sqlite-async.js to a dynamic import() which is available in all CommonJS modules.
;
Can someone advise how to use deal with these errors.I tried (js/import "sqlite-async" no luck
:js-options {:module-rules {"sqlite-async" {:type :esm}}} hilarious. this does not and has never existed ๐
:esm does not currently support a REPL for ndoe targets, so this will not work
you can still use the regular build just fine though. just can't do anything at the repl
:js-options {:module-type :es6} also doesn't exist
and the build config is missing the :modules config
see the example here https://clojureverse.org/t/generating-es-modules-browser-deno/6116
I took those options based on Claude AI advice. When I looked in manual they were not there. I thought it must be undocumented option. Turns out it is just LLM hallucination.
I see an old response from you on clojureverse where you mentioned require of ES modules is not supported is a node issue
I will try the build
:esm is the correct choice to get around the node limitation, just need to use config options that actually exist ๐
:use-node-modules true has also never existed
My shadow-cljs.edn as support for es6 I guess
{:dependencies
[[org.clojure/core.async "1.7.701"]
[hiccup "2.0.0-RC4"]
[funcool/promesa "11.0.678"]]
:source-paths
["src"]
:builds
{:app {:target :esm
:output-to "target/app.js"
:output-dir "out"
:main mynodeapp.main/main
:js-options {:module-type :es6}
:compiler-options {:output-feature-set :es-next ; Use modern JS features
:use-node-modules true}http://Claude.ai suggested to add `:js-options {:module-rules {"sqlite-async" {:type :esm}}} :compiler-options {:infer-externs :auto}` to shadow-cljs.edn
It did not work