This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-01
Channels
- # announcements (3)
- # babashka (20)
- # beginners (77)
- # calva (27)
- # cider (5)
- # clara (3)
- # clj-kondo (9)
- # cljs-dev (4)
- # cljsrn (5)
- # clojure (26)
- # clojure-europe (32)
- # clojure-italy (5)
- # clojure-nl (3)
- # clojure-uk (5)
- # clojurescript (25)
- # clojureverse-ops (4)
- # core-async (49)
- # cursive (15)
- # data-science (1)
- # datahike (4)
- # datomic (3)
- # docker (1)
- # events (1)
- # helix (5)
- # holy-lambda (3)
- # introduce-yourself (1)
- # jobs (1)
- # kaocha (2)
- # lsp (15)
- # malli (42)
- # off-topic (18)
- # pathom (18)
- # pedestal (12)
- # polylith (7)
- # rdf (1)
- # re-frame (22)
- # reitit (2)
- # releases (1)
- # remote-jobs (1)
- # rewrite-clj (33)
- # shadow-cljs (85)
- # spacemacs (3)
- # vim (12)
- # xtdb (29)
I am getting a compile error of a project that was working. And I have no idea what it coudl be:
failed to resolve: ./iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js {:require-from #object[java.io.File 0x41bf4c6e "/home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js"], :require "./iterator.js"} ExceptionInfo: failed to resolve: ./iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js shadow.build.npm/find-file (npm.clj:464)
try { // add if support for Symbol.iterator is present require('./iterator.js')(Yallist$1); } catch (er) {}
I have no idea where iterator.js could come from. VEGA has 12 npm repos, and so many dependencies. typescript, etc.
@hoertlehner @alex.sheluchin that to me looks like a conditional require of some sort. shadow-cljs expects to find that file but doesn't. in fact nothing ever will find that so I don't know why that code is even in there. it appears to be new in the 6.20.0 release. 6.19.1 does not have it and likely compiles fine. or just create that file with just module.exports = function() {};
should be enough
Not the first time something "unexpected" happens inside the Vega builds. I'll file an issue there about this too, but I don't have high hopes of getting it fixed unless someone understands their build system well enough and digs into it
https://github.com/vega/vega-embed/issues/780 for those who are affected
yeah, their entire build system seems rather messed up. no clue why this is in the released builds, it can't serve any purpose
var scripts$1 = {
prebuild: "yarn clean && yarn build:style",
build: "rollup -c",
"build:style": "./build-style.sh",
clean: "del-cli build build-es5 src/style.ts",
prepublishOnly: "yarn clean && yarn build",
preversion: "yarn lint && yarn test",
serve: "browser-sync start --directory -s -f build *.html",
start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
pretest: "yarn build:style",
test: "beemo jest --stdio stream",
"test:inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
prepare: "beemo create-config",
prettierbase: "beemo prettier '*.{css,scss,html}'",
eslintbase: "beemo eslint .",
format: "yarn eslintbase --fix && yarn prettierbase --write",
lint: "yarn eslintbase && yarn prettierbase --check",
release: "auto shipit"
};
I've gotten the feeling that perhaps build systems aren't their forte, but I don't know the background on how they then chose the tools they are using right now
A shame, really. The library has/had great potential, but I guess is severly lacking just contributors/maintainers in general, or at least those well versed in JS tooling
@hoertlehner you could just use "vega-embed": "6.19.1",
in your package.json
if you don't really need anything in the newest release.
@U05224H0W and @U8ZQ1J1RR thanks for looking into this. Not the greatest start with vega, but it was recommended as a good starting point for charting, so I'm going to stick with it a while and see if issues like this are frequent.
I rather see it as the end point, not the starting point. It's pretty heavy duty. But that's a discussion for another thread (and channel).
I fixed it by including this version. But I would like to know how I could fix it via the module.export.
@hoertlehner I think you can just include an iterator.js
file with the contents module.exports = function() {};
. https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries might be helpful.
./iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js
means it was trying to find /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/iterator.js
but couldn't since it does not exist
but how can I add a directory to a npm temporary directory? I would need to first know when cljs watch has finihed getting the npm dependencies, so I could then manually add this file.
I think if you just put the file in a mirrored location somewhere on your classpath, it should get picked up correctly when building.
but if you run npm install
just before everything should already be ready and shadow-cljs won't install anything
It's not an extra dependency anyway if it's already a subdependency of something you use.
Ah, no, that's my mistake. You would need to put it next to the vega-embed.js file. But yeah, best option is to just roll back to a working release.
Coming back to this, would the module version of the vega-embed work better? That is, if you have :js-options {:entry-keys ["module" "browser" "main"]}
in the build target.
https://unpkg.com/browse/[email protected]/build/vega-embed.module.js seems to be packaged completely differently and doesn't seem to try to import the missing file
Hi 👋 I have two targets that compile some of the same code, one :browser
and one :npm-module
. For some reason automatic externs inferring isn’t working in :npm-module
(and adding a line like :compiler-options :externs ["externs.js"]
doesn’t help either) and so I get warnings for the :npm-module
target that don’t show up in the :browser
target. The warnings seem to be coming from using imported Node modules (so they necessarily must be JS functions)
Is there something that needs to be done additionally to get externs inferring to work for :npm-module
?
@slack1338 for :browser
shadow-cljs processes all JS and can infer a bunch of externs from that. for :npm-module
that is not done since something else will provide the JS dependencies so you probably need a few more typehints
I’m guessing it’s not possible or simple to assume any node module is JS and automatically infer that anything imported from it is ^js
?
I’ll try to come up with a minimal reproduction case and post here when I do. In any case from what I can tell it seems that the same code, compiled using these different targets, leads to different inferences and at least in this case code that should be inferred at JS isn’t in the :npm-module
target. I assume it’s because, as you mention, the :browser
target processes the JS code while the :npm-module
target doesn’t
Type hints would solve it but we don’t need them for our current app code (we don’t get warnings for the :browser
compilation target) since the automatic externs inferring works in that case so it’s not a solution we would prefer to use if possible
why not? they won't hurt the browser build and will in fact make it more reliable given that the compiler doesn't have to guess anymore.
Well, primarily because we don’t need them for the browser build. In any case I will make a minimal repro repo and share with you here later
@U05224H0W So we talked about adding type hints internally and are okay with it. I went ahead and tried to do it based on my understanding of how it should work and I think I uncovered a bug, but need more input - long story short in :target :npm-module
target, if you use a JS function in a binding, and then later use that result in an anonymous function, it doesn’t seem to keep track of it even with a type hint and you’re forced to add a type hint in the anon function. https://github.com/jo-sm/shadow-externs-repro if you want to take a look, I tried to describe it as clearly as I can and am open to any ideas you have
this is somewhat expected. you are welcome to make a enhancement patch for CLJS but as of now externs inference is not that smart
but also kind of ambiguous. objects
is a JS value as hinted (so probably an array) but you are map'ing over it and it does not automatically imply that each item in that array is also a JS value
Sure, but the issue doesn’t appear with the :target :browser
mode (even with externs inferring fully disabled), and it doesn’t get fixed with type hints as I understand them from the official reference. So I feel like something isn’t working as expected
An alternative would be to just silence the warnings using :compiler-options {:warnings {:infer-warning false}}
but I am also struggling to get that to work for :npm-module
Anyway, if you have any ideas how to get around this let me know. The simplest approach would be to just shut the warnings up but it doesn’t seem to work (if I’m misplacing or misspelling the option, let me know), but adding type hints is also viable, but it also seems to work in an unexpected way (if my repro and understanding are correct)
everything is working as intended. you found the correct place to add the typehint. just do exactly that.
sure, but disabling the warnings seems to do nothing
and disabling the warnings will most likely lead to broken builds so just don't do it
the warnings still appear in the terminal
in this specific case disabling the warnings is acceptable as this is for tests, not for the main build of our application
imho you should still run your tests using :advanced
release builds. still might catch issues in your main build
I’m a bit confused still - externs and :advanced
aside, is it possible to disable warnings for :npm-module
?
you can try setting :js-options {:generate-externs false}
in your :browser
build config
I’m still missing the answer to my question 😅
let me try it
you can also set (set! *warn-on-infer* false)
in a file after the ns
or so to turn off all warnings in that file only
but I repeat that the warnings are there for a reason and you probably spent more time talking to me about that problem than adding a few ^js
would take
ah ok so :infer-externs false
does indeed fix it. Does it work differently than just disabling the warning (or does disabling the warning not work as I expect, which is that it won’t output it if it encounters it)?
disabling the warning likely just conflicts with the other setting defaulting to be enabled and overriding that setting
Yeah it’s not that we are definitely going to disable the extern warnings - as you said they’re there for a reason - it’s more that we want to have the option to. In this specific case they’re being compiled for tests where we would expect the tests to fail for other reasons and this warning isn’t as relevant (unlike for the main build where it is more relevant). I was more trying to figure out why exactly the way that it seems like it should work according to the docs (adding :warnings {:infer-warning false}
) wasn’t
and the warnings are not coming from import node modules. the warnings come from your cljs files
yarn shadow-cljs server
is supposed to open a process that runs forever, until Cntl C out of it. But this morning, after an (attempted) OS upgrade, this is what I'm getting:
[chris@chris-latitudee7470 rad-b00ks]$ yarn shadow-cljs server
yarn run v1.22.15
$ /home/chris/rad-b00ks/node_modules/.bin/shadow-cljs server
shadow-cljs - config: /home/chris/rad-b00ks/shadow-cljs.edn
shadow-cljs - connected to server
Done in 0.13s.
The process terminates! Same with yarn shadow-cljs watch
. Actually yarn shadow-cljs server
works fine for another project, with these two lines popping up after the config line:
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.15.12 running at
, and the process lasting forever as expected. There are no recently written log files to help diagnose, not in in the project root directory anyway.Fixed by first deleting the .shadow-cljs
directory that must have become corrupted. Doubt it had anything to do with the OS upgrade.