Skip to content
New issue

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

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

Already on GitHub? # to your account

babel-plugin-minify-constant-folding creates wrong strings when combined with babel-polyfill #499

Closed
ATGardner opened this issue Apr 15, 2017 · 2 comments

Comments

@ATGardner
Copy link

I keep getting a runtime exception when trying to load a minified bundle that uses babel-polyfill and lodash. I extracted the failed code, and created a simple example of the error.

My package.json contains the following dependencies
"babel-core": "^6.24.0", "babel-loader": "^6.4.1", "babel-polyfill": "^6.23.0", "babel-preset-env": "^1.4.0", "babili-webpack-plugin": "^0.0.11", "webpack": "^2.4.1",

The code creates
'use strict'; I(114); var Y = /[a-c\xdf-\xf6]+(?=[A-C\xc0-\xd6])/g, H = '[a-z\\\\xdf-\\\\xf6]+(?=' + ['[A-Z\\xc0-\\xd6]'].join('|') + ')', W = RegExp(H, 'g'); console.log('success');
(After running prettier on the main.bundle.js file)

from the main.js. You can see that the H variable has some extra escape characters, which cause the RegExp constructor to fail.
If I uncomment the evaluate: false or comment the library: 'main' line from webpack.config.js or comment the import 'babel-polyfill'; from main.js, the resulting main.bundle.js file contains a properly escaped string, and the RegExp constructor passes.

@hzoo
Copy link
Member

hzoo commented Apr 15, 2017

Hey @ATGardner! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@goto-bus-stop
Copy link
Contributor

This was fixed in #490, but it's not released yet.

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

No branches or pull requests

4 participants