2017-01-28 5 views
1

私は、メインアプリケーションへのエントリポイントである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" 
} 
... 

答えて

0

"build": "npm run cleanup && ngc -p tsconfig.build.json && npm run bundling && npm run minify && npm run copy"
関連する問題