Common misconception: ES Modules are required to do scope hoisting and static analysis.
-
Show this thread
-
The way 99% of the population use CJS, is static. If you use webpack or parcel, the only way they can work is if your requires are static.
1 reply 0 retweets 2 likesShow this thread -
You can also easily remove function wrappers from CJS modules by rewriting all local variables, constructing export objects and rewriting all local variables to refer to it, and compile anything else that requires() the file to refer to that object.
1 reply 0 retweets 4 likesShow this thread -
Then you can do an optimizing pass to kill the object completely if it's never introspected. eg. you only ever refer to the object properties and never pass the bare reference around.
1 reply 0 retweets 3 likesShow this thread -
Replying to @sebmck
Heh, this is exactly how our implementation works. https://github.com/parcel-bundler/parcel/tree/master/src/scope-hoisting …
1 reply 0 retweets 1 like -
Replying to @devongovett @sebmck
I was originally interested in doing something like this, but I couldn't figure out how to make it work for modules like [pull-stream](https://ghub.io/pull-stream ) that use for loops to construct `exports`.
1 reply 0 retweets 0 likes
You would keep the objects in that case
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 