从 Typescript 2.0.10 升级到 2.1.4 似乎破坏了 webpack、webpack-stream、ts-loader 或 gulp 中的某些内容,因为它不再尊重我的入口点或 gulp 源 glob。它似乎包括我的项目中的所有 .ts 文件(包括 /server 源文件夹中的文件),而不仅仅是 /client 和 app.ts 中的 ts 文件,根据 gulp.src 和 web pack 入口点。我应该这样做有不同/更新/更好的方式吗?
在 gulp 文件中:
const serverPath = 'server';
const clientPath = 'client';
const buildPath = 'build';
const paths = {
server: {
scripts: [
`${serverPath}/**/*.ts`
]
},
client: {
files: [
`${clientPath}/**/*`
],
scripts: [
`${clientPath}/**/*.ts`
],
entry: `${clientPath}/app.ts`
}
};
gulp.task('build:client', cb => {
gulp.src(paths.client.entry)
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest(`${buildPath}/${clientPath}`));
cb();
});
在 web 包配置中:
entry: {
app: './client/app.ts'
}
ts: {
configFileName: './tsconfig.json'
}
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
}
module: {
loaders: [
{ test: /\.ts$/, loader: 'ng-annotate-loader!ts-loader' }
]
}
在 tsconfig.json 中:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"removeComments": false,
"noImplicitAny": true,
"sourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
使用 2.0.10 输出:
ts-loader: Using typescript@2.0.10 and /Users/chris/code/class-app/tsconfig.json
[20:47:36] Version: webpack 1.14.0
Asset Size Chunks Chunk Names
app.js.map 950 bytes 0 [emitted] app
app.js 550 bytes 0 [emitted] app
使用 2.1.4 输出:
ts-loader: Using typescript@2.1.4 and /Users/chris/code/class-app/tsconfig.json
server/api/thing/thing.controller.ts(17,16): error TS2322: <ts error in server portion, not relevant>
[20:53:03] TypeScript: 1 semantic error
[20:53:03] TypeScript: emit succeeded (with errors)
Unhandled rejection Error in plugin 'webpack-stream'
Message:
/Users/chris/code/class-app/server/api/thing/thing.controller.ts <same as above>