This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-17
Channels
- # announcements (7)
- # babashka (24)
- # beginners (11)
- # boot (16)
- # calva (46)
- # cider (5)
- # clara (3)
- # clj-kondo (2)
- # cljfx (5)
- # clojure (122)
- # clojure-brasil (26)
- # clojure-dev (20)
- # clojure-europe (20)
- # clojure-germany (1)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-uk (2)
- # clojurescript (6)
- # core-matrix (23)
- # datomic (85)
- # graalvm (1)
- # honeysql (9)
- # hyperfiddle (31)
- # lsp (3)
- # malli (9)
- # nbb (2)
- # off-topic (15)
- # pathom (15)
- # pedestal (4)
- # polylith (5)
- # re-frame (5)
- # reitit (9)
- # releases (2)
- # shadow-cljs (63)
- # specter (4)
- # xtdb (7)
I tried to import this lib https://pdfmake.github.io/docs/0.1/getting-started/client-side/methods/ “pdfmake”, any idea how to import.. I got everytime errors, I don’t know how to import this lib in the right way (ns require) Yes, I know the docs url [https://shadow-cljs.github.io/docs/UsersGuide.html#npm] and I imported other npm libs without problem.. I saw that is closure compiler problem in the prev posts/ messages.
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/pdfmake/build/pdfmake.js"]]}
ExceptionInfo: failed to convert sources
shadow.build.closure/convert-sources-simple*/fn--57322 (closure.clj:1998)
shadow.build.closure/convert-sources-simple* (closure.clj:1997)
shadow.build.closure/convert-sources-simple (closure.clj:2169)
shadow.build.closure/convert-sources-simple (closure.clj:2121)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1233)
shadow.build.compiler/compile-all (compiler.clj:1461)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:493)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:360)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:538)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:495)
shadow.cljs.devtools.server.util/server-thread/fn--60595/fn--60596/fn--60604 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--60595/fn--60596 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--60595 (util.clj:241)
java.lang.Thread.run (Thread.java:833)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
Invalid node in lhs: STRINGLIT / 13037:4 [length: 15] [source_file: node_modules/pdfmake/build/pdfmake.js] [original_name: __dirname]
Node(GETELEM): node_modules/pdfmake/build/pdfmake.js:13044:0
exports["default"] = void 0;
Parent(ASSIGN): node_modules/pdfmake/build/pdfmake.js:13044:0
exports["default"] = void 0;
I'm using Antlr4 in my project, besides its module that I'm installing with NPM it generates js files that import the Antlr4 module. I'm having a reaaaaaally hard time trying to advance-compile it. By my research I saw that I have to define everything that shouldn't be renamed in my externs/app.txt
, but as Antlr4 lib is huge I'd take ages to write it by checking errors and including in the .txt file.
Am I missing something? Is there a way shadow-cljs recognizes the Antlr4 lib and avoid renaming everything that it's there? I've also downloaded the Antlr4 package to import it as a local lib, but it didn't change much.
don't know enough about your setup to answer. npm deps do not go through :advanced
, so require no externs
so how do you import the generated js file? and what does a file like that look like?
I require them as .js files https://github.com/JpOnline/looset-graph/blob/d423c047f36a924c8400e1691d260cb431e1359e/src/main/looset_graph/graph_parser.cljs#L4
can you tell antlr to generate commonjs files? not esm? so no import/export? but require, module.exports?
that will process the files like any other npm package, so no :advanced
probably no externs required
OMG it worked.. I spent so long on it :face_holding_back_tears: How can I thank you @U05224H0W? Maybe adding this tip to the UsersGuide?
your previous method is actually the preferred one, I just haven't found a good way to "fix" it yet
I created a PR for it https://github.com/shadow-cljs/shadow-cljs.github.io/pull/95
However, I dont think the tip should be “wrap js files in NPM package”. It should be “js files imported in clojurescript go through advanced optimizations. if you would like to avoid this, then set up an npm package and require that instead”
well, technically there is nothing stopping me from just disabling advanced for these files and treating them exactly like npm code
and that may be the better choice from a developer experience side, I opted for :advanced
because I maybe was too optimistic about it?
i wouldnt say optimistic… if you look at how antlr automatically generates JS code, it violates basically all of the rules on google’s website for writing javascript that can survive advanced compilation
this is anecdotal evidence, but i would say ~90% of JS files I import directly survive advanced compilation, the 10% is when I rely on auto-generated JS from tools like ANTLR 😛
Is it possible to create a module-manifest with module-hash-names while targeting the esm
format?
so shadow-cljs release app --config-merge '{:output-dir "wherever/v1"}'
and then use v2
and so on
manifest you don't really need since esm can just load the files it needs and doesn't need a loader
okay sounds good. does that mean i don’t need to worry about manifest being used for anything else? And are you saying that the module-loader can be replaced by esm module loading?
yup yup i understand, i guess i meant to ask if i’m moving from :browser
to :esm
targets that I can still module load stuff
it also isn't necessary, since you can just use (shadow.esm/dynamic-import "./the-other-module.js")
I require them as .js files https://github.com/JpOnline/looset-graph/blob/d423c047f36a924c8400e1691d260cb431e1359e/src/main/looset_graph/graph_parser.cljs#L4
I come across recently into that error:
[2023-08-17 17:07:31.633 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
AssertionError Assert failed: (map? rc)
shadow.build.resolve/maybe-esm-rewrite (resolve.clj:208)
shadow.build.resolve/maybe-esm-rewrite (resolve.clj:208)
shadow.build.resolve/eval12490/fn--12492 (resolve.clj:422)
clojure.lang.MultiFn.invoke (MultiFn.java:244)
shadow.build.resolve/find-resource-for-string (resolve.clj:81)
shadow.build.resolve/find-resource-for-string (resolve.clj:70)
shadow.build.resolve/resolve-string-require (resolve.clj:460)
shadow.build.resolve/resolve-string-require (resolve.clj:443)
shadow.build.resolve/resolve-require (resolve.clj:675)
shadow.build.resolve/resolve-require (resolve.clj:668)
shadow.build.resolve/resolve-deps/fn--12393 (resolve.clj:52)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
Worker shutdown.
Latest shadow, latest cljs, build with :js-provider :external
.In the repo, here is shadow, webpack and babel to handle typescript. The error happen every time when generated classes are missing
hmm that doesn't seem like an error from :external
? I mean that shouldn't even be calling that code?
hmm ok that should be the error you get for file not found? so I'm guessing you have absolute require that doesn't exst
you might be the first to use classpath js with :external
, either are not very common. together you are probably the first 😉
Here is the demo project: https://github.com/rynkowsg/demo-shadow-amplify The goal there is to: • use libraries like aws-amplify (that shadow can't resolve on its own) • use typescript in the same repo
I'm not very much familiar with shadow internals, but it looks shadow looks for node dependencies and fails
This is the error if I let shadow to resolve the deps:
[:dev] Build failure:
The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/dist/cjs/node-http2-handler.js".
Dependency Trace:
demo/main/core.cljs
node_modules/aws-amplify/lib/index.js
node_modules/@aws-amplify/core/lib/index.js
node_modules/@aws-amplify/core/lib/Providers/index.js
node_modules/@aws-amplify/core/lib/Providers/AWSCloudWatchProvider.js
node_modules/@aws-sdk/client-cloudwatch-logs/dist/cjs/index.js
node_modules/@aws-sdk/client-cloudwatch-logs/dist/cjs/CloudWatchLogsClient.js
node_modules/@aws-sdk/client-cloudwatch-logs/dist/cjs/runtimeConfig.js
node_modules/@aws-sdk/node-http-handler/dist/cjs/index.js
node_modules/@aws-sdk/node-http-handler/dist/cjs/node-http2-handler.js
Searched for npm packages in:
/home/user/Sources/obrizum/shadow-amplify/node_modules
/home/user/Sources/obrizum/shadow-amplify/src/js/components
:face_vomiting: just looked at the aws-amplify package again. I remembered why I try to forget every time I see that 😛
lets just require everything in the entire world, and rely on the build tool removing 99% of it ...
ok, I don't mind. I experienced similar mediocre quality with aws deps dedicated to run on android, so I guess they are consistent 🙂
This is the error if I let shadow to resolve the deps:
[:dev] Build failure:
The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/dist/cjs/node-http2-handler.js".
Dependency Trace:
demo/main/core.cljs
node_modules/aws-amplify/lib/index.js
node_modules/@aws-amplify/core/lib/index.js
node_modules/@aws-amplify/core/lib/Providers/index.js
node_modules/@aws-amplify/core/lib/Providers/AWSCloudWatchProvider.js
node_modules/@aws-sdk/client-cloudwatch-logs/dist/cjs/index.js
node_modules/@aws-sdk/client-cloudwatch-logs/dist/cjs/CloudWatchLogsClient.js
node_modules/@aws-sdk/client-cloudwatch-logs/dist/cjs/runtimeConfig.js
node_modules/@aws-sdk/node-http-handler/dist/cjs/index.js
node_modules/@aws-sdk/node-http-handler/dist/cjs/node-http2-handler.js
Searched for npm packages in:
/home/user/Sources/obrizum/shadow-amplify/node_modules
/home/user/Sources/obrizum/shadow-amplify/src/js/components