Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 巴别塔7&;SystemJS 2:“;无法解析裸说明符core js/modules/web.dom.iterable“;_Javascript_Node.js_Babeljs_Systemjs - Fatal编程技术网

Javascript 巴别塔7&;SystemJS 2:“;无法解析裸说明符core js/modules/web.dom.iterable“;

Javascript 巴别塔7&;SystemJS 2:“;无法解析裸说明符core js/modules/web.dom.iterable“;,javascript,node.js,babeljs,systemjs,Javascript,Node.js,Babeljs,Systemjs,我将Babel 7与polyfill和systemjs插件一起使用,这会导致以下错误: Unhandled promise rejection Error: Error loading file:///.../myproject/node_modules/core-js/modules/web.dom.iterable from file:///.../myproject/target/main.js Stack trace: h.instantiate/</<@file:///..

我将Babel 7与polyfill和systemjs插件一起使用,这会导致以下错误:

Unhandled promise rejection Error: Error loading file:///.../myproject/node_modules/core-js/modules/web.dom.iterable from file:///.../myproject/target/main.js
Stack trace:
h.instantiate/</<@file:///.../myproject/node_modules/systemjs/dist/system.min.js:4:4817
core.min.js
未处理的承诺拒绝错误:“无法解析文件:///[…]/target/main.js”中的裸说明符“core js/modules/web.dom.iterable”

我如何告诉Babel生成可以在SystemJS中无错误运行的传输代码

传输的代码如下所示:

"use strict";

System.register(["core-js/modules/web.dom.iterable", "core-js/modules/es6.set", "./loadGraphFromSparql.js", "./log.js", "./filter.js", "./menu.js", "./search.js", "./button.js", "./graph.js", "./file.js", "./rdfGraph.js", "./layout.js", "./progress.js"], function (_export, _context) {
  "use strict";
package.json

{
  [...]
  "dependencies": {
    "@babel/polyfill": "^7.0.0",
    "cytoscape": "^3.2.17",
    "cytoscape-cxtmenu": "^3.0.1",
    "cytoscape-euler": "^1.2.1",
    "spin.js": "^4.0.0",
    "systemjs": "^2.0.1"
  },
  "devDependencies": {
    "@babel/cli": "^7.1.2",
    "@babel/core": "^7.1.2",
    "@babel/plugin-transform-modules-systemjs": "^7.0.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/register": "^7.0.0",
    "chai": "^4.2.0",
    "docdash": "^1.0.0",
    "es6-promise": "^4.2.5",
    "eslint": "^5.6.1",
    "eslint-plugin-import": "^2.14.0",
    "isomorphic-fetch": "^2.2.1",
    "jsdoc": "^3.5.5",
    "mocha": "^5.2.0",
    "node-localstorage": "^1.3.1"
  },
  [...]
  "scripts":
  {
    "build": "babel js -d target", [...]
  }
}
.babelrc

{
  "presets":
  [[
    "@babel/preset-env", {
      "targets": {
        "chrome": 52,
        "browsers": ["Firefox 49", "Edge 12","Chrome 53", "Opera 41", "Safari 10"]
      },
      "useBuiltIns": "usage"
      }]],
  "plugins": ["@babel/plugin-transform-modules-systemjs"]
}
编辑: 根据@loganfsmyth的建议,我删除了对@babel polyfill的依赖。我还添加了一个systemjs packagemap来包含裸导入。不幸的是,这会导致以下错误:

Unhandled promise rejection Error: Error loading file:///.../myproject/node_modules/core-js/modules/web.dom.iterable from file:///.../myproject/target/main.js
Stack trace:
h.instantiate/</<@file:///.../myproject/node_modules/systemjs/dist/system.min.js:4:4817
core.min.js
未处理的承诺拒绝错误:加载错误file:///.../myproject/node_modules/core-js/modules/web.dom.iterable 从…起file:///.../myproject/target/main.js
堆栈跟踪:

h、 实例化/参见巴别塔的文档,了解
预设环境
使用内置
选项:

此选项将直接引用添加到核心js模块作为裸导入。因此,核心js将相对于文件本身进行解析,并且需要可访问。您可能需要指定核心-js@2如果没有核心js依赖项或存在多个版本,则将其作为应用程序中的顶级依赖项


因此,您需要依赖于
包.json中的
“core js”:“^2.5.7”
,然后您需要确保代码已绑定到应用程序中。

@babel/polyfill已被弃用,因此请使用以下两种:

npm i --save core-js regenerator-runtime
然后删除
导入“@babel/polyfill”

再加上这两个

import "core-js/stable";
import "regenerator-runtime/runtime";
如本文所述


我以为core js已经通过@babel/polyfill包含在内了。根据:“Babel包含一个包含自定义再生器运行时和core js的polyfill。”如果您使用的是
@Babel/polyfill
,那么您不希望
“使用内置”:“用法”
。它们是两种不同的多边形填充方法,因此您可能希望使用其中一种或顺序。我将把您的代码和更改放在GitHub中,以防它起作用。或者如果有人能修好它。