私は、メインアプリケーションへのエントリポイントであるindex.ts
ファイルとテストセットアップのエントリポイントであるtest.ts
を持つAngular2ライブラリプロジェクトに取り組んでいますカルマを開始し、テスト.ts
のテストをインポートします)。私のtsconfig.json
ファイル(以下に含まれています)には両方のエントリーファイルが含まれています。これは開発とテストの間にうまく動作しますが、ビルドを実行するときにはtest.ts
ファイルも含まれています。 test.ts
ファイルをfiles
アレイから削除した場合Webstormはコードベースのデコレータの使用がすべてエラー(experimental support for decorators is a feature that is subject to change in a future release...
)であるとマークします。Angular2 tsconfig - ビルド中にエントリポイントとしてファイルを除外する
IDEがtsconfig.json
ファイルをテストファイルに使用するように修正する方法はありますが、ビルド時には含まれていませんか?
// tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"noImplicitAny": true,
"module": "es2015",
"moduleResolution": "node",
"paths": {
"@angular/core": ["node_modules/@angular/core"],
"@angular/testing": ["node_modules/@angular/testing"],
"rxjs/*": ["node_modules/rxjs/*"]
},
"allowSyntheticDefaultImports": true,
"rootDir": ".",
"outDir": "dist",
"sourceMap": true,
"inlineSources": true,
"target": "es5",
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"node_modules/@types"
]
},
"files": [
"index.ts",
"test.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
}
*参考のためにスクリプトを構築する第二のTSconfigファイル(tsconfig.build.json
)を作成し、そのファイルを使用するようにbuild
スクリプトを更新することで解決
// package.json
...
"scripts": {
"cleanup": "rimraf dist/bundles dist/src dist/index.d.ts dist/index.js dist/index.js.map dist/LICENCE dist/README.md",
"bundling": "rollup -c",
"minify": "uglifyjs dist/bundles/my-library.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/async-local-storage.umd.min.js",
"copy": "copyfiles LICENSE README.md dist",
"build": "npm run cleanup && ngc && npm run bundling && npm run minify && npm run copy"
}
...