After upgrading from Typescript 2.0.10 to 2.1.4, it seems that something in webpack, webpack-stream, ts-loader, or gulp is not working correctly. It no longer respects the entry point or gulp source glob specified; instead, it includes all .ts files in the project, even those in the /server source folder, rather than just the ts files in /client and app.ts as intended. Is there a better way to handle this with the newer version?
Here is the relevant code snippet from the gulp file:
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();
});
Here is the relevant code snippet from the webpack configuration:
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' }
]
}
And here is the content of tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"removeComments": false,
"noImplicitAny": true,
"sourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
Output with Typescript 2.0.10:
ts-loader: Using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="097d70796c7a6a7b60797d493b2739273839">[email protected]</a> 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
Output with Typescript 2.1.4:
ts-loader: Using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85f1fcf5e0f6e6f7ecf5f1c5b7abb4abb1">[email protected]</a> 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>