我有以下package.json
:
{
"name": "watchman",
"version": "1.0.0",
"description": "Simple watcher for ES6 to AMD conversion",
"author": "Luciad NV",
"license": "MIT",
"scripts": {
"build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 babel es6/geometry es6/ria es6/symbology -d release --watch"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.1",
"babel-preset-env": "^1.7.0",
"cross-env": "^5.2.0"
}
}
我有以下.babelrc
:
{
"presets": ["babel-preset-env"],
"plugins": ["transform-es2015-modules-amd"]
}
我的es6/ria
文件夹中有以下es6模块:
import Object from "./Dependency";
export default {
};
如果我运行npm run build
,则会生成具有以下实现的AMD模块:
define(["exports", "./Dependency"], function (exports, _Dependency) {
"use strict";
_Dependency2.default.defineProperty(exports, "__esModule", {
value: true
});
var _Dependency2 = _interopRequireDefault(_Dependency);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
exports.default = {};
});
如您所见,_Dependency2
仅在引用_Dependency2.default
之后才定义,这会引发错误。
我做错什么了吗?还是这是Babel中的错误?