0

我正在将现有的 Aurelia 应用程序从 JSPM/SystemJS 移植到 Aurelia CLI。

我无法获得babel-runtime和相关的转换来工作au build。我认为问题是由于babel-runtime所需的依赖关系aurelia.json- 我无法弄清楚它应该是什么,目前它看起来如下所示:

...
{
   "name": "babel-runtime",
   "path": "../node_modules/babel-runtime",
   "main": "core-js",
   "resources": [
     "./regenerator/index.js"
   ]
}
...

我有以下(相关的)devDependencies:

...
"babel-plugin-syntax-flow": "^6.8.0",
"babel-plugin-transform-async-to-generator": "^6.22.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-amd": "^6.8.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.10.3",
"babel-plugin-transform-es2015-modules-systemjs": "^6.9.0",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-stage-1": "^6.5.0",
"babel-register": "^6.9.0"
...

和(相关)依赖项:

"babel-runtime": "^6.23.0",

我的.babelrc

{
  "sourceMap": true,
  "moduleIds": false,
  "comments": false,
  "compact": false,
  "code": true,
  "presets": [
    ["es2015", {"loose": true}],
    "stage-1"
  ],
  "plugins": [
    "syntax-flow",
    "transform-decorators-legacy",
    "transform-async-to-generator",
    ["transform-runtime", {
      "polyfill": false,
      "regenerator": true
    }],
    "transform-flow-strip-types",
    ["transform-builtin-extend", {
        "globals": ["Array"]
    }]
  ]
}

au build我得到以下类别的错误:

File not found or not accessible: D:/code/.../node_modules/babel-runtime/regenerator.js. Requested by D:\code\...
File not found or not accessible: D:/code/.../node_modules/core-js/library/fn/symbol.js. Requested by D:\code\...

可以在 Aurelia CLI 应用程序中成功设置的人提供babel-runtime帮助吗?

更新

我已经设法通过列出它似乎引用的所有babel-runtime和依赖项来使构建工作......这是正确的方法吗?core-js

{
  "name": "babel-runtime",
  "path": "../node_modules/babel-runtime",
  "main": "core-js"
},
{
  "name": "babel-runtime/regenerator",
  "path": "../node_modules/babel-runtime/regenerator",
  "main": "index"
},
{
  "name": "babel-runtime/core-js",
  "path": "../node_modules/babel-runtime/core-js"
},
{
  "name": "core-js",
  "path": "../node_modules/core-js",
  "main": "index"
},
{
  "name": "core-js/library",
  "path": "../node_modules/core-js/library",
  "main": "index"
},
{
  "name": "regenerator-runtime",
  "path": "../node_modules/regenerator-runtime",
  "main": "runtime-module"
},
...

但是我现在看到来自 require 的运行时错误,这似乎表明我的依赖项没有以正确的顺序加载

Uncaught Error: Module name "_export" has not been loaded yet for context: _. Use require([])
Uncaught Error: Module name "shim" has not been loaded yet for context: _. Use require([])

有人能帮忙吗?

4

1 回答 1

1

我已经设法让它工作了......我从一个空白的石板开始,并一个一个地添加了移动部件,但是 Aurelia CLI 也有一些更新,所以我不完全确定它是否是什么东西我做错了,或者 CLI 中存在已解决的问题。

.babelrc现在非常简单,stage-1 预设足以使异步转换工作:

{
  "sourceMap": true,
  "moduleIds": false,
  "comments": false,
  "compact": false,
  "code": true,
  "presets": [
    ["es2015", {"loose": true}],
    "stage-1"
  ],
  "plugins": [
    "transform-runtime",
    "transform-decorators-legacy"
  ]
}

core-jsbabel-runtime相关的捆绑包依赖项aurelia.json是:

"dependencies": [
  {
    "name": "core-js",
    "path": "../node_modules/core-js",
    "main": "client/core",
    "deps":[
      "../node_modules/core-js/shim",
      "../node_modules/core-js/library/**/*.js",
      "../node_modules/core-js/modules/**/*.js"
    ]
  },
  {
    "name": "regenerator-runtime",
    "path": "../node_modules/regenerator-runtime",
    "main": "runtime"
  },
  {
    "name": "babel-runtime",
    "path": "../node_modules/babel-runtime",
    "main": "regenerator/index",
    "deps": [
      "../node_modules/babel-runtime/core-js/**/*.js",
      "../node_modules/babel-runtime/helpers/**/*.js"
    ]
  },
  {
    "name": "babel-runtime/regenerator",
    "path": "../node_modules/babel-runtime/regenerator",
    "main": "index"
  },

  ...

和 package.json 相关的位:

"dependencies": {
    ...
    "babel-runtime": "^6.23.0",
    "core-js": "^2.4.1",
    ...
  },
  "devDependencies": {
    ...
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-es2015-modules-amd": "^6.8.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.10.3",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.13.2",
    "babel-preset-stage-1": "^6.5.0",
    ....
  }

希望这可以帮助其他试图完成这项工作的人!

于 2017-05-12T00:28:17.260 回答