【发布时间】:2015-02-06 16:25:38
【问题描述】:
我真的很喜欢angular's core modules,我正在尝试在 node/io.js 环境中使用其中的一些功能;即:将 Angular 模块转换为 commonjs 格式的 ES5 模块。
我尝试使用 traceur 手动构建 Angular 模块,但没有成功(生成循环依赖),还尝试调整 Angular 项目的 gulpfile.js 以生成 commonjs 格式的 ES5 输出:
var _COMPILER_CONFIG_JS_DEFAULT = {
sourceMaps: true,
annotations: true, // parse annotations
types: true, // parse types
script: false, // parse as a module
memberVariables: true, // parse class fields
modules: 'commonjs'
};
... 正在运行 build/transpile.js.dev 任务,但我一直面临这条消息:
TypeError: Cannot call method 'map' of undefined
即使更改默认配置中的sourceMaps,我也无法摆脱这个map 错误。
我还注意到他们的编译器工具,它似乎实际上处理了输出格式。但我没有机会改变它的选择。我只能在 System.register 格式的文件中使用默认配置,而我无法转换为 commonjs。
经历过这一切的人有没有在 commonjs 风格的项目中使用 angular 模块的解决方案?请注意,我想将其用作库,并且不想将我的项目转换为另一种类型的模块系统。
欢迎任何建议,谢谢!
【问题讨论】:
-
实际上我尝试在节点环境中使用 Angular,而不是将 AMD 与 Angular 结合使用。无论如何感谢您的建议!
标签: angularjs node.js ecmascript-6 porting traceur