Closed nelsyeung closed 7 years ago
Hm ... why you need to add babel-polyfill
to the webpack.config.js
file. By import
ing it you are already including it in the bundle.
@krasimir Because of this documentation: https://babeljs.io/docs/usage/polyfill/ I've tried removing the import 'babel-polyfill';
from the beginning of "src/index.js" and it's still not working. Also tried using just the import 'babel-polyfill'
instead of the entry inside webpack.config.js
.
I see ... what if you not importing it. I mean using only the addition to webpack.config.js
file.
I've tried every single combinations: 1) Have both the import and webpack entry: not working 2) Have only the import in index.js: not working 3) Have only the webpack entry: not working 4) Without the import and webpack entry: working (lol basically just your package so of course its working)
Thanks. I'll investigate.
Sorry about this, I shouldn't even be using babel-polyfill
for a library. The reason why this doesn't work is because webpack build for the browsers but Mocha is running tests in node, so it wouldn't have the window
object to store _babelPolyfill
, therefore undefined. I will close this issue now.
I'm trying to get babel-polyfill working with for a library but I'm getting the following error:
Full replication details:
Add
import 'babel-polyfill';
to the beginning of "src/index.js".Add
'babel-polyfill'
to "webpack.config.js":Then build and test: