SystemJS Builder + Babel issue
SystemJS Builder + Babel issue
我正在尝试SystemJS,并在尝试将构建器与babel一起使用时遇到问题。
这是一个简单的ES2015项目,所以不会让你厌烦它的细节,但我的捆绑设置如下所示。
配置.js:
System.config({
transpiler: 'babel',
paths: {
'babel': './node_modules/babel-core/lib/api/browser.js'
}
});
建造者.js:
var path = require("path");
var Builder = require('systemjs-builder');
var builder = new Builder('.', 'config.js');
builder
.buildStatic('./src/app.js', './dist/index.js')
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});
我收到以下错误:ReferenceError: require is not defined
babel 的browser.js
文件。在添加 babel 路径之前,我收到一个错误,即 SystemJS 试图相对于我的源目录定位babel.js
。
我显然在这里错过了一些简单的东西,但文档并不完全直截了当,而且在 babel 方面似乎有点过时了。在与 SystemJS 捆绑之前,我是否需要在文件上运行 babel 以便 require 可用或其他什么?
对此并不乐观,因为我使用 jspm,所以我不必手动设置它,但看起来 babel-core 的正确主文件是 ./node_modules/babel-core/browser.js
它具有"格式全局"; 而不是"格式化 cjs"; 这将解释您的错误。
相关文章:
- issue with FB.Event.subscribe
- 如何在javascript上使用flak-babel进行翻译
- 将webpack和babel与父项目目录中的文件一起使用
- 转换成ES 5使用babel通过吞咽手表不工作
- Babel编译错误:找不到模块核心js/library/fn/get迭代器
- 使用Jquery Issue垂直重新排序Divs
- 创建了一个选项卡,但点击时不会起作用-jQuery issue/newbie
- babel with sub js files
- jQuery find() Issue
- Babel/Mocha:Mocha已全局安装,但未定义describe()
- 使用babel,我如何将一些代码附加到每个文件的顶部
- 可以't让browserfy使用babel-plugin-transform类属性
- $route.reload(); Issue
- 使用systemJS的相对动态加载,使用ES6/Babel语法
- 正在导出带有ES6(Babel)的类
- PHP json_encode issue
- 试图将类导出为模块ES6-babel
- 和babel一起哼哼,浏览
- Three.js issue creating meshes outside of loader's load(
- SystemJS Builder + Babel issue