TypeScript 2.1.4 violation of changes in webpack ts-loader

Upgrading from Typescript from 2.0.10 to 2.1.4, it looks like something broke in webpack, webpack-stream, ts-loader or gulp, as it no longer takes into account my entry point or gulp source glob. Apparently, it includes all the .ts files in my project (including the source folder / server), and not just the ts files in / client and app.ts according to the entry point of gulp.src and the web package . Is there any other / newer / better way that I should do this?

in 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(); }); 

in web package 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' } ] } 

in tsconfig.json:

 { "compilerOptions": { "module": "commonjs", "target": "es6", "removeComments": false, "noImplicitAny": true, "sourceMap": true, "inlineSources": true, "experimentalDecorators": true, "emitDecoratorMetadata": true } } 

Exit using 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 

Exit using 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> 
+2
source share
1 answer

Apparently the TypeScript problem in WebPack was running all the time on the server code (although it shouldn't have been), and although I planned to fix the TS server problem that TypeScript updated, it really exposed that WebPack was collecting files that it shouldn't have . I tested this by deliberately presenting the problem to the ts server in the previous ("working") version of TypeScript, getting the same error.

I still need to find out why it is trying to compile all my TS files, not just those in / client, but I will ask a new question for this.

+2
source

Source: https://habr.com/ru/post/1261738/


All Articles