I'm using parcel with this npm script (minifying app.js from compiling PureScript to js):
"prod": "pulp browserify -O --to build/app.js && parcel build build/app.js",
It used to work without problems, but now I always get this error:
> D:\docs\purescript-halogen-template\build\app.js:12147:21: Cannot resolve dependency '_process'
12145 | PS["Main"].main();
12146 |
> 12147 | }).call(this,require('_process'))
| ^
12148 | },{"_process":1}]},{},[2]);
12149 |
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `pulp browserify -O --to build/app.js && parcel build build/app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache\_logs\2018-02-02T00_21_51_286Z-debug.log
Any idea what is causing this? :)
Wait, so you're running browserify, and then running the output through Parcel? Why?
Because parcel makes it smaller. I tested it (like I said it was working before)..
Maybe it does more minification or dead code elimination?
@Boscop Parcel is a bundler itself, so there鈥檚 no need to run your project through browserify first.Can you please try running it through only Parcel, and see if you鈥檙e still getting the error when you run it directly through Parcel without browserify?
My non-minified way of building my app.js is:
pulp build -O --to dist/app.js
This results in app.js being 934kb.
The above error (about _process) happens when I do:
pulp browserify -O --to build/app.js && parcel build build/app.js
When I don't browserify, only build and parcel, like this:
pulp build -O --to build/app.js && parcel build build/app.js
Then the resulting app.js is 373kb but doesn't work correctly:
The app normally starts with a login form, sends a /login request with json body and json result, and after successful login the page DOM gets re-rendered according to the role of the logged-in user (customer or driver).
But when I use parcel like above the app stops working after the login form: The /login request is sent (using affjax), so it's not the case that the generated JS code doesn't work at all.
BUT: the response from the /login request doesn't seem to get processed, and the DOM is not re-rendered but stays at the login form, so the parceled app is unuseable.
Any idea why that happens or how to fix it?
We don鈥檛 recommend running your app through a different build tool in addition to Parcel, as it can cause some issues, and plenty of duplicate work. You should use only Parcel by itself (with the plugins that you need), instead of using Pulp and then running the output through Parcel.
I鈥檓 gonna close this issue for now, since it鈥檚 a pretty specific use case, but please send me a message on slack so I can try to work on this with you directly 馃槃 馃憤
I understand, but running Pulp is necessary (because pulp is the PureScript to JS compiler). Without that, there would be no JS to minify in the first place.
Pulp doesn't do any minification etc. that's why I'm using parcel.
Late reply, but yeah, what is needed here is to use pulp build / purs bundle like so: https://github.com/justinwoo/vidtracker/blob/6d651f6b5b378fe239c1a0245c92e5bc8eff8b1d/package.json#L14
Running Parcel on both the normal commonJS /output and a built bundle (not through pulp browserify) has been working well for me for a long time now :+1: