Is it possible to avoid the addition of the parcelRequire helper in the case of a JS bundle which does not use require or any sort of module feature in the target script?
I pass a simple script to parcel which does not use any require or import and I'd like to reduce the overhead produced by parcel.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel |1.11.0
| Node |8.11.3
| Yarn | 1.13.0
| Operating System |
You could use --experimental-scope-hoisting.
(This is quite hard to implement in the current pipeline)
related to #2451
@mischnic As seen in #2451, the real problem that I have is the "Mismatched anonymous define()" error. Would it be that difficult to handle? What's your take on this @devongovett?
@mischnic How reliable is that flag? It certainly looks to work on trivial cases.
How reliable is that flag? It certainly looks to work on trivial cases.
It even works in most complex cases ๐. I'd say it's quite reliable now, there are only some edge cases left. Please try it and open an issue if you find one!
@mischnic As the flag is "experimental", any idea when this should be ready for production?
@devongovett Should this really be closed? An experimental flag is not the same as being completed.
The flag didn't work for me. For test purposes I only have one script file with a console.log() included at the end of my HTML file. So there is definitely no reason for parcelRequire() here.
This is my build task:
"build": "parcel build index.html --out-dir build --no-minify --no-source-maps --experimental-scope-hoisting",
If someone could explain to me, if I have a single js file - why do I need to require anything inside the js file (parcelRequire) if it's all inside that file? i.e. what is parcelRequire actually for?
why do I need
It isn't needed, but the current approach is: take the wrapper and insert all JS modules. The unfortunate side-effect of this simplification is that a single JS module also has the wrapper code.
@jhpratt I agree. Can we keep this open?
For Parcel 2, scope hoisting (which has no such wrapper) enabled by default in production builds. So I would say this is already somewhat fixed.
Most helpful comment
@devongovett Should this really be closed? An experimental flag is not the same as being completed.