首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Webpack突破IE11

Webpack突破IE11
EN

Stack Overflow用户
提问于 2017-07-28 02:21:58
回答 1查看 2.5K关注 0票数 3

很难追踪到这一点,所以谢谢你的忍耐。一些用户抱怨我们的网站在IE11中崩溃了。这款应用使用的是nextjs 3.0.1和webpack 2.7.0。

在开发模式下调试

我想我有一个类似于Angular RxJs timer pausing on IE11的问题。在IE11中,我从名为webpack/webpack引导x(其中x是一些十六进制数字)的引用中得到一个错误。

下面是导致这个问题的函数:

代码语言:javascript
复制
// 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配置):

代码语言:javascript
复制
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应用程序的生产版本中遇到了一个不同的问题。它位于next生成的app.js文件的深层,但错误似乎来自这行https://github.com/ianstormtaylor/heroku-logger/blob/master/src/index.js#L12

代码语言:javascript
复制
const {
  LOG_LEVEL,
  NODE_ENV,
} = process.env

它正在抛出Expected identifier。这是因为模块没有正确地从ES6转换到ES5吗?这可能是一个潜在的问题(我在开发中看到的),而不是heroku-logger库的问题。

意识到这是一个复杂的问题,我可能遗漏了一些细节。提前感谢您的帮助!

EN

回答 1

Stack Overflow用户

发布于 2017-07-29 01:11:12

为了防止其他人遇到这个问题,我将babel-polyfill保留在了webpack的配置中,并将build命令更改为:

代码语言:javascript
复制
next build && babel .next/*.js --out-dir . --presets=es2015,react

这是相当笨重的,因为一些代码被webpack巴别化,然后又在输出目录中。会喜欢其他的建议!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45358349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档