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.
-
-
Show 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.
Show 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.
Show this thread
End of conversation
New conversation -
-
-
Yep.
@parceljs supports tree shaking CommonJS too!
-
Nice! I actually looked into it when I was playing around with bundling. Stopped looking when I noticed it used Babel which is pretty fragile, especially when you're doing binding renaming. How have you found the stability? Any patterns in particular you found hard to transform?
- 3 more replies
New conversation -
-
-
Not sure if this applies completely to ^^, but I’ve always thought common-shake was an interesting project - https://github.com/indutny/common-shake …
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
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 