ロールアップを使用して製品版を構築するためのこのチュートリアルに従っていました: http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/
本番部分はうまく機能していますが、npm run start
(js ディレクトリをクリーンアップし、.ts ファイルをコンパイルし、変更を監視するスクリプト) を使用して開発したい場合、ビルドは失敗し、404
それが見つかりませんでしたという例外が表示されます
traceur
。注目すべき唯一の違いは、ファイル内の fromes5
とcommonjs
toの変更です。これを修正してライトサーバーを機能させるにはどうすればよいですか。es2015
tsconfig
エラー
GET http://localhost:3000/traceur 404 (Not Found)
scheduleTask @ zone.js:1561
ZoneDelegate.scheduleTask @ zone.js:242
Zone.scheduleMacroTask @ zone.js:168
(anonymous) @ zone.js:1584
send @ VM1385:3
fetchTextFromURL @ system.src.js:1051
(anonymous) @ system.src.js:1781
ZoneAwarePromise @ zone.js:525
(anonymous) @ system.src.js:1780
(anonymous) @ system.src.js:2809
(anonymous) @ system.src.js:3387
(anonymous) @ system.src.js:3701
(anonymous) @ system.src.js:4093
(anonymous) @ system.src.js:4556
(anonymous) @ system.src.js:4825
(anonymous) @ system.src.js:407
ZoneDelegate.invoke @ zone.js:229
Zone.run @ zone.js:113
(anonymous) @ zone.js:509
ZoneDelegate.invokeTask @ zone.js:262
Zone.runTask @ zone.js:151
drainMicroTaskQueue @ zone.js:405
ZoneTask.invoke @ zone.js:336
(index):44 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/traceur
Error: XHR error (404 Not Found) loading http://localhost:3000/traceur
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:851:29) [<root>]
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:151:47) [<root> => <root>]
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:332:33) [<root>]
Error loading http://localhost:3000/traceur
Unable to load transpiler to transpile http://localhost:3000/js/main.js
Error loading http://localhost:3000/js/main.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:851:29) [<root>]
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:151:47) [<root> => <root>]
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:332:33) [<root>]
Error loading http://localhost:3000/traceur
Unable to load transpiler to transpile http://localhost:3000/js/main.js
Error loading http://localhost:3000/js/main.js
古いバージョン
{
"compilerOptions":{
"target":"ES5",
"module":"commonjs",
"moduleResolution":"node",
"sourceMap":true,
"emitDecoratorMetadata":true,
"experimentalDecorators":true,
"removeComments":false,
"noImplicitAny":false,
"inlineSourceMap":false,
"inlineSources":false,
"outDir":"js"
},
"exclude":[
"node_modules",
"typings/main",
"typings/main.d.ts"
],
"compileOnSave":true
}
新しいバージョン
{
"compilerOptions":{
"target":"es2015",
"module":"es2015",
"moduleResolution":"node",
"lib":[
"es6",
"es2015",
"dom"
],
"sourceMap":true,
"emitDecoratorMetadata":true,
"experimentalDecorators":true,
"removeComments":false,
"noImplicitAny":false,
"inlineSourceMap":false,
"inlineSources":false,
"outDir":"js",
"typeRoots":[
"./node_modules/@types",
"./node_modules"
],
"types":[
]
},
"exclude":[
"node_modules",
"typings/main",
"typings/main.d.ts"
],
"compileOnSave":true
}
system.config.js
/** * System configuration for Angular samples * Adjust as necessary for your application needs. */
(function(global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
app: 'js',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'primeng': 'npm:primeng',
'@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js'
},
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
primeng: {
defaultExtension: 'js'
}
}
});
})(this);