stealjs / steal-tools

Build easy. Load fast.

Home Page:https://stealjs.com/docs/steal-tools.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

treeshaking force compiling to ES5

pYr0x opened this issue · comments

Hey,
i had an issue with await and compiling to ES6. i used the new forceES5: false option to avoid compiling to ES5. it worked on stealjs (in the browser). But if i want to create a bundle, steal-tools will compile all my code to ES5, if treeshaking is on.
Here is my Slack issue: https://bitovi-community.slack.com/archives/CFDDX9MJS/p1582789198006000

And here is my demo: https://github.com/pYr0x/steal-es6
use npm run build to create a bundle. In the generated index.js i will find code like

var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {

which mean that that await is compiled to a es5 generator function

when you are working with es6 @pYr0x i can supply you a working rollup config with remove-steal and steal-resolve support at last for canjs it does not support the additional hackish steal imports like ~ or module/module while i am not really sure about the latest

but at last you could do a real es6+ build of canjs also using lebab to fix and clean the canjs source so that it is really working without double assignments to var names and all this object patching avoided.

it is not perfect as I still will need to do a complete independent fork of canjs to fix all the design issues. but it produces the best working es6 build of canjs that is possible today with that legacy code.

conclusion

if your modules are using real valid ECMAScript syntax for imports you can use rollup + myconfig to create awsome ESNext canjs bundels.

hey @frank-dspeed, it would be nice if you can share your rollup config in a github gist.