我正在尝试让 babel-polyfill 与库一起使用,但出现以下错误:
TypeError: Cannot read property '_babelPolyfill' of undefined
at Object.<anonymous> (/Users/foo/webpack-library-starter/lib/library.js:73:6)
...
我使用webpack-library-starter作为我的模板。
完整复制详细信息:
git clone https://github.com/krasimir/webpack-library-starter.git
cd webpack-library-starter
npm i
npm i --save babel-polyfill
尝试添加import 'babel-polyfill'
到“src/index.js”的开头并没有它。
添加'babel-polyfill'
到“webpack.config.js”:
entry: ['babel-polyfill', __dirname + '/src/index.js'],
然后构建并测试:
npm run dev
npm run build
npm test