-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bundling is broken #68
Comments
Thanks for the report. Sorry for the delay. I will get back to this next On Monday, 26 September 2016, Dmitry Smolin [email protected]
|
This definitely requires a bit more digging on my part. However, I wonder if it may be worth evaluating the pros/cons of keeping the bundling feature. If you don't mind my asking, do you see a significant improvement in the end result of the JS in a production build from webpack with bundling enabled vs. disabled? |
Yes, it's significant. Especially if you are careful and do not reference JS modules from PureScript code. It reduces code size a lot. |
Gotcha. I will look into a possible solution to this. |
Thank you! |
here is quick and dirty fix I'm using right now (just to demonstrate possible fix idea): |
Thanks for the diff. Just so I understand, is it that we have to wait for all of the non-PureScript modules in general to have |
Also, you don't happen to have a small use-case that reproduces this issue, do you? |
Potentially, it could be reproduced by adding artificial huge delay to JS modules processing (add setTimeout or something to JS loader) and having several JS modules to import very small PureScript ones. I will try to create sample project with this, but probably you can do it faster by just modifying JS loader directly in
|
Thank you for the details on how to reproduce this. I am wondering if there might be a webpack plugin hook that we can leverage in the loader to run Another hook that might work is if we can use the |
I may be experiencing a comparable issue, and using |
purs-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 havemodule.building
equals toundefined
(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.The text was updated successfully, but these errors were encountered: