[英]Webpack breaking in IE11
很难追踪到这一点,所以感谢与我的关系。 一些用户抱怨我们的网站在IE11中被破坏了。 该应用程序使用nextjs 3.0.1和webpack 2.7.0。
我想我有一个类似于IE11上的Angular RxJs计时器暂停的问题 。 我在IE11中从一个名为webpack /// webpack bootstrapxxxxxxxxxx(其中x是十六进制的数字)的引用中收到错误。
这是导致问题的功能:
// The require function
function __webpack_require__(moduleId) {
// Check if module is in cache
if(installedModules[moduleId]) {
return installedModules[moduleId].exports;
}
// Create a new module (and put it into the cache)
var module = installedModules[moduleId] = {
i: moduleId,
l: false,
exports: {},
hot: hotCreateModule(moduleId),
parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp),
children: []
};
// Execute the module function
var threw = true;
try {
modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
threw = false;
} finally {
if(threw) delete installedModules[moduleId];
}
// Flag the module as loaded
module.l = true;
// Return the exports of the module
return module.exports;
}
行modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
抛出错误Unable to get property 'call' of undefined or null reference
。
我想这是因为缺少polyfill,所以我按照https://github.com/zeit/next.js/issues/1254上的建议将其添加到next.config.js(下一个webpack配置):
const originalEntry = config.entry
config.entry = function () {
return originalEntry()
.then((entry) => {
Object.keys(entry).forEach(k => {
entry[k].unshift('babel-polyfill')
})
console.log(entry)
return entry
})
}
我仍然看到同样的错误。
有趣的是,我在nextjs应用程序的生产版本中有一个不同的问题。 它深入下一个生成的app.js
文件,但错误似乎来自这一行https://github.com/ianstormtaylor/heroku-logger/blob/master/src/index.js#L12 :
const {
LOG_LEVEL,
NODE_ENV,
} = process.env
它正在抛出Expected identifier
。 这是因为模块没有正确地从ES6转换为ES5吗? 可能存在一个潜在的问题(我在开发中看到),而不是heroku-logger
库的问题。
意识到这是一个复杂的问题,我可能错过了一些细节。 在此先感谢您的帮助!
如果其他人与此搏斗,我将babel-polyfill
polyfill留在webpack配置中并将build
命令更改为:
next build && babel .next/*.js --out-dir . --presets=es2015,react
这非常笨重,因为有些代码是由webpack进行的,然后再次出现在输出目录中。 会喜欢其他建议!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.