bundling is broken
See original GitHub issuepurs-loader starts bundling right after the compilation, but it does not guarantee that all the references to the PureScript modules are already collected. As a result, if compilation ends faster than modules processing, this code continues to add bundle modules that will never be bundled (because bundling is already started at this time).
I’ve got this problem compiling a large JS project with some of PureScript included, while compiling for the server side. For some reason bundling for client side either worked well or problems weren’t obvious.
At least, I’d recommend to throw an error if more bundle modules are tried to be pushed when bundling is already started because else bundle is invalid anyway.
I don’t see any easy way to fix the problem. It’s needed to somehow wait for all the modules except PureScript ones to be processed before starting bundling. It can be done with checking _compilation.modules
and not starting bundling unless all non-.purs
of them have module.building
equals to undefined
(see this code). I couldn’t find any better way to determine webpack have finished with the module. Anyway, it looks hacky.
Also, because all the modules must be ready before bundling, PureScript files cannot be used in loaders or as loaders with bundle: true
mode. This looks pretty obvious, but probably should be documented. A workaround here can be to use special non-bundling settings for loaders, but haven’t tried it myself yet.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
Gotcha. I will look into a possible solution to this.
Yes, it’s significant. Especially if you are careful and do not reference JS modules from PureScript code. It reduces code size a lot.