我非常喜欢角的核心模块,我试图在节点/io.js环境中使用其中的一些特性,即:将转换成ES5模块,并将其转换为格式的ES5模块。
我试图一个一个地构建角度模块,但是没有成功(生成循环依赖项),并尝试修改gulpfile.js的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/tran溢出e.js.dev任务,但我一直面临这样的消息:
TypeError: Cannot call method 'map' of undefined即使通过在默认配置中更改sourceMaps,我也无法消除这个map错误。
我还注意到了他们的转换程序工具,它似乎实际上处理输出格式。但我没有机会改变它的选择。我只能在System.register格式的文件中使用默认配置,而这些文件是我无法转换为公共文件的。
有没有人经历过这一切,有一个解决方案,使用角的模块,在一个公共风格的项目?请注意,我希望将它用作一个库,并且不希望将我的项目转换为另一种类型的模块系统。
欢迎任何建议,谢谢!
发布于 2015-01-03 21:48:52
使用CommonJS包装器映射角模块,如下面的示例:
# angular is required globally
{{name}} = angular.module '{{name}}', []
module.exports = {{name}}发布于 2015-02-04 02:57:03
我认为使用角度模块以及构建步骤将所有文件连接到一个主文件中是一种很好的方法。
这是我正在工作的一个项目的gulpfile.js。
var gulp = require('gulp');
var concat = require('gulp-concat');
var path = 'app/js/';
var srcFiles = [path + 'midi.js',
path + 'keyboard.js',
path + 'analyser.js',
path + 'services/amp.js',
path + 'services/lfo-amp.js',
path + 'services/osc.js',
path + 'services/filter.js',
path + 'services/lfo.js',
path + 'audio.js',
path + 'synth.js',
path + 'app.js'];
gulp.task('default', function () {
gulp.src(srcFiles)
.pipe(concat('app.js'))
.pipe(gulp.dest('dist/js/'))
});gulp.src接受要连接的文件数组,并将保持所有文件的正确顺序。现在,您可以将您的角度项目分解成任意大小的主文件,而不必担心通过加载一堆脚本标记来压缩服务器。
https://stackoverflow.com/questions/27367751
复制相似问题