是否可以将lru-cache编译到浏览器

时间:2018-11-21 21:16:52

标签: javascript webpack babeljs

我正在尝试使一个使用Webpack编译的Internet Explorer应用程序运行,并且该应用程序依赖于lru-cache节点模块。在我的webpack配置中没有过多的细节,我得到了这个错误。

HTML1300: Navigation occurred.
app
TypeError: Cannot modify non-writable property 'length'
   {
      [functions]: ,
      __proto__: { },
      description: "Cannot modify non-writable property 'length'",
      message: "Cannot modify non-writable property 'length'",
      name: "TypeError",
      number: -2146823209,
      stack: "TypeError: Cannot modify non-writable property 'length'
   at defineProperty (http://localhost/app/dist/main.bundle.js:4637:5)
   at defineProperties (http://localhost/app/dist/main.bundle.js:4645:17)
   at promisify (http://localhost/app/dist/0.bundle.js:105745:2)
   at promisify (http://localhost/app/dist/0.bundle.js:105646:2)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:106141:130)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:106109:29)
   at __webpack_require__ (http://localhost/app/dist/main.bundle.js:50:12)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:153527:773)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:153527:29)
   at __webpack_require__ (http://localhost/app/dist/main.bundle.js:50:12)",
      Symbol()_m.c1jtqv4wbmm: undefined,
      Symbol()_n.c1jtqv4wbmm: undefined,
      Symbol()_p.c1jtqv4wbmm: undefined,
      Symbol()_q.c1jtqv4wbmm: undefined,
      Symbol()_r.c1jtqv4wbmm: undefined,
      Symbol(foo)_o.c1jtqv4wbmm: undefined
   }


Unhandled promise rejection TypeError: Cannot modify non-writable property 'length'
   "Unhandled promise rejection"
   {
      [functions]: ,
      __proto__: { },
      description: "Cannot modify non-writable property 'length'",
      message: "Cannot modify non-writable property 'length'",
      name: "TypeError",
      number: -2146823209,
      stack: "TypeError: Cannot modify non-writable property 'length'
   at defineProperty (http://localhost/app/dist/main.bundle.js:4637:5)
   at defineProperties (http://localhost/app/dist/main.bundle.js:4645:17)
   at promisify (http://localhost/app/dist/0.bundle.js:105745:2)
   at promisify (http://localhost/app/dist/0.bundle.js:105646:2)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:106141:130)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:106109:29)
   at __webpack_require__ (http://localhost/app/dist/main.bundle.js:50:12)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:153527:773)
   at Anonymous function (http://localhost/app/dist/0.bundle.js:153527:29)
   at __webpack_require__ (http://localhost/app/dist/main.bundle.js:50:12)",
      Symbol()_m.c1jtqv4wbmm: undefined,
      Symbol()_n.c1jtqv4wbmm: undefined,
      Symbol()_p.c1jtqv4wbmm: undefined,
      Symbol()_q.c1jtqv4wbmm: undefined,
      Symbol()_r.c1jtqv4wbmm: undefined,
      Symbol(foo)_o.c1jtqv4wbmm: undefined
   }

原因似乎是lru-cache在'length'上使用了Object.defineProperty。有没有babel插件可以容纳这个?我看到了https://babeljs.io/docs/en/babel-plugin-transform-es5-property-mutators,但这似乎将get / set更改为defineProperty元素,而不是解决了它

我可能可以使用其他LRU模块,但是它需要更改许多依赖关系,甚至可能依赖于依赖关系

0 个答案:

没有答案