Fork me on GitHub
#shadow-cljs
<
2019-06-15
>
pez07:06:46

I don’t remember the details about :npm-module problems, just that I, with your assistance, couldn’t make it to work. It was something with the entry point.

pez07:06:12

Webpack is what the vscode packager suggests that I pack my extension with for releases. And when I do that it shrinks it down from thousands of files and 20 MB. To one file of 1.6 MB.

thheller09:06:19

@pez I can't remember the :npm-module problems either but it should be working fine. just may need to create one additional file manually or so. thats the part that :node-library basically does for you.

thheller09:06:47

not sure what webpack does that shadow-cljs release wouldn't do?

thheller09:06:33

or do you use many JS deps that need to be bundled as well? not sure how exactly vscode exts are packaged

pez10:06:18

So, in Calva, the cljs-lib is a small library, giving the TypeScript code (which is most of the code) access to some clojure facilities, like the cljs.reader and clj-fmt. The vsce packager greates a zip file with file extension .vsix, in which cljs-lib.js, created by shadow-cljs release is just one of the files. If I include Webpack in the build chain, it bundles all the js files into one, and vsce stops complaining about that I should use webpack. And the extension installs much faster and works excellently.

pez10:06:25

As for :npm-module problems. You and I really gave that a shot, back then. But we reached a point where you said, “use :node-library instead”. Which is where I am now. I can of course try with :npm-libarary again, but I don’t like the idea of spending days to again find out it won’t work. 😃

thheller10:06:35

well :node-library is never gonna work with webpack during development and what you describe is easily possible with :npm-module

thheller10:06:45

would help to remember why that was causing issues but I can't 😛

pez10:06:39

I think I can give it a quick try and we'll see if it works or at least what the problem is.

thheller10:06:22

FWIW going through webpack is still gonna limit your development capabilities

thheller10:06:37

so live reload and REPL will be questionable regardless

pez10:06:46

You're right. Which points me in the direction of trying to not use webpack for dev and only for release. Which brings me back to the question about if you think I can rely on that the release build are currently working swell.

pez11:06:01

Yeah, so when I let webpack bundle things it works, but only in realease. In dev there are references to things in the .shadow-cljs dir that don't resolve. But, as you say, I might lose the repl and hot reload anyway with webpack, so not worth trying to solve that resolve problem.

thheller11:06:11

yes :node-library will NEVER work with webpack during development

thheller11:06:40

basically all targets make certain assumptions about the runtime they are gonna be using

thheller11:06:08

:node-library as the name implies assumes it will be running in node which is not true if you package it with webpack first

thheller11:06:51

it also assumes it can use the node runtime facilities to load code dynamically which is also not possible when using webpack

thheller11:06:38

so the only thing you'd gain with :npm-module+webpack during development is that it becomes loadable

thheller11:06:50

live-reload and REPL probably won't work reliably

pez11:06:54

I’ll avoid webpack for dev. And things the release build with webpack works, I can safely use that?

thheller11:06:44

yes release builds are just one file and don't do any dynamic loading

metal 4
mhuebert13:06:39

hm, I am running into an obscure issue with shadow.loader in a production build. Module loading isn’t working, and I’ve determined that shadow.loader.initCalled is undefined. The problem goes away when I enable --debug mode, which makes me think maybe it has something to do with an advanced-mode name collision of some kind. I haven’t been able to reproduce locally, only when it is built on our CI server. (Just posting here in case some possible avenue to look at comes to mind, i’ll keep debugging)

thheller13:06:15

do you get an actual reference to shadow.loader.initCalled in the optimized code?

mhuebert13:06:57

I get a reference to the shadow.loader object,

mhuebert13:06:04

it doesn’t contain an initCalled key

mhuebert13:06:32

hmm. if I call init I do see shadow.loader.init was already called!

thheller13:06:37

how do you get a reference to that object?

mhuebert13:06:51

window.shadow.loader

thheller13:06:02

yeah thats only the exported stuff

thheller13:06:24

closure will have rewritten that and may have removed the property

mhuebert13:06:16

ok. probably unrelated to the issue then.

thheller13:06:32

what is the issue?

mhuebert13:06:08

it repeatedly tries to load the same modules, and fails, only returning 1 as the error (which i believe just means ’consecutive errors`

mhuebert13:06:29

repeated network calls for the same module:

thheller13:06:53

assuming thats a 200 ok response?

thheller13:06:04

it may be throwing an error on load

thheller13:06:17

ie throwing an exception when the code is evaluated

thheller13:06:41

you can try loading the code directly without the loader

thheller13:06:52

just via normal <script> tags in the correct order

thheller13:06:58

makes debugging a bit easier

mhuebert13:06:09

will try that.

mhuebert13:06:16

oh… maybe this is a caching issue. When I load modules normally I append a hash as a query param, eg. dropify.js?v=<hash>

mhuebert13:06:49

the module loader could be getting invalid/old versions

mhuebert13:06:28

i’ll try a script tag without the query param to double check.

thheller13:06:15

then use :module-hash-names true 😉

4
mhuebert14:06:55

So, caching was indeed the issue. And using :module-cache-names was the solution.

Mudge21:06:25

Hey there, how do I specify what the init function is used when using :modules {:entries something.core} ?

Mudge21:06:09

Inside the :builds map

Mudge21:06:59

Anybody here?

thheller21:06:00

:modules {:main {:init-fn some.core/init}}

Mudge21:06:37

Thanks but I want to use the entries map too

thheller21:06:51

nothing stopping you from doing that

thheller21:06:08

:modules {:main {:init-fn some.core/init :entries [foo.bar]}}

Mudge21:06:19

ohhh, thanks!

Mudge21:06:02

@thheller I just started using shadow-cljs today. I really like it

👍 8
Mudge22:06:39

Is the manifest.edn needed in the release version of the build? Could I remove it or would that mess stuff up?

Mudge22:06:56

Is it needed to make code splitting work?

thheller22:06:55

it is not needed no

Mudge22:06:42

okay, thanks