私はモジュールロードのためにSystemJSでTypescriptを使用し、Angular 2プロジェクトではタスクランナーのためにGulpを使用しています。プロジェクトのAngularの現在のバージョンはRC2ですが、問題はRC1でも発生しています。私はbrandoの答えhereの手順に従った。私のアプリケーションやウェブサイトのSystemJSの初期負荷をバンドルした後GulpとSystemJSを使ってAngular 2 Typescriptアプリをバンドルするには?
でエラーが発生します:
Error: http://localhost:57462/app/app.bundle.js detected as register but didn't execute.
アプリケーションは動作しますが、コンソールのエラーは間違いなく良いことではありません。
空のプロジェクトで私の設定をテストしましたが、問題が再現しているので、設定に問題があると思います。ここで
それは次のとおりです。
Gulpfile
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var typescript = require('gulp-typescript');
var jspm = require('gulp-jspm-build');
gulp.task('compile:ts', function() {
return gulp.src(['./appTS/**/*.ts'])
.pipe(sourcemaps.init())
.pipe(typescript({
noEmitOnError: true,
target: 'ES5',
removeComments: false,
experimentalDecorators: true,
emitDecoratorMetadata: true,
module: 'system',
moduleResolution: 'node'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./app/'));
});
gulp.task('copy:vendor', function() {
return gulp.src([
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/core-js/client/shim.min.js',
'node_modules/zone.js/dist/zone.min.js',
'node_modules/systemjs/dist/system.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./assets/vendor/'));
});
gulp.task('bundle:app', ['compile:ts'], function() {
return jspm({
bundleOptions: {
minify: true,
mangle: false
},
bundleSfx: true,
bundles: [
{ src: './app/main.js', dst: 'bundle.js' }
]
})
.pipe(gulp.dest('./app/'));
});
gulp.task('bundle', ['bundle:app', 'copy:vendor'], function() {
return gulp.src([
'./assets/vendor/Reflect.js',
'./assets/vendor/shim.min.js',
'./assets/vendor/zone.min.js',
'./app/bundle.js'])
.pipe(concat('app.bundle.js'))
.pipe(gulp.dest('./app/'))
});
gulp.task('default', ['bundle']);
var packages = {
app: {
format: 'register',
defaultExtension: 'js'
},
"symbol-observable": { main: 'index.js', defaultExtension: 'js' },
"reflect-metadata": { main: 'Reflect.js', defaultExtension: 'js' }
};
var ngPackageNames = ['common',
'compiler',
'core',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade'];
ngPackageNames.forEach(function (element, index, array) {
packages['@angular/' + element] = { main: 'bundles/' + element + '.umd.min.js', defaultExtension: 'js' };
});
System.config({
main: 'dispel.bundle.min',
defaultExtension: 'js',
format: 'register',
packages: packages,
baseURL: "/",
defaultJSExtensions: true,
transpiler: false,
paths: {
"node_modules*": "node_modules*",
"@angular*": "node_modules/@angular/*"
},
map: {
"@angular": "node_modules/@angular",
"symbol-observable": "node_modules/symbol-observable",
"ng2-translate": "node_modules/ng2-translate",
"es6-shim": "node_modules/es6-shim",
"reflect-metadata": "node_modules/reflect-metadata",
"rxjs": "node_modules/rxjs",
"zone.js": "node_modules/zone.js"
}
});
あなたは私たちがクローンを作成できレポやテストを作成することはできますか? – Sasxa
また、あなたが 'system' /' register'フォーマットを使用している理由は何ですか? TSコンバイナで ''モジュール '':commonjs ''を、システム設定で' 'フォーマット':" cjs "'を使用するとどうなりますか? – Sasxa
特に理由はありません。エラーはSystemJSによってスローされなくなりましたが、新しいエラーがありました: 'crypto.js not found'。 System.config - > mapセクションで "crypto": "node_modules/crypto-js/index.js"のマッピングを追加しましたが、SystemJSはすべてのcrypto-jsファイル(約30)に対して別々の要求を行います。 –