在构建工具`parcelJs`中:生成的代码无法运行

问题描述 投票:0回答:1

当parcel编译我的代码时,它构建js文件就像这样:

"use strict";

// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles

require = function (_require) {
  function require(_x, _x2, _x3) {
    return _require.apply(this, arguments);
  }

  require.toString = function () {
    return _require.toString();
  };

  return require;
}(function (modules, cache, entry) {
...

该代码无法运行,因为它试图在“use strict”模式下定义不带require的变量var|let|const

所以我的问题是:为什么它会生成这样的条形码?

javascript build parcel parceljs
1个回答
0
投票

所以在this tread他们说升级节点到8.0.0或更高版本解决了这个问题。

以一种有趣的方式BTW ......它神奇地从生成的文件中删除了use strict

© www.soinside.com 2019 - 2024. All rights reserved.