Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treeshaking force compiling to ES5 #1156

Open
pYr0x opened this issue Feb 27, 2020 · 2 comments
Open

treeshaking force compiling to ES5 #1156

pYr0x opened this issue Feb 27, 2020 · 2 comments
Labels

Comments

@pYr0x
Copy link
Contributor

pYr0x commented Feb 27, 2020

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

@pYr0x pYr0x changed the title treeshaking ignores compiling to ES6 treeshaking force compiling to ES5 Feb 27, 2020
@matthewp matthewp added the bug label Feb 27, 2020
@frank-dspeed
Copy link
Contributor

frank-dspeed commented Mar 16, 2020

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.

@pYr0x
Copy link
Contributor Author

pYr0x commented Mar 16, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants