@@ -5,6 +5,7 @@ const nsWebpack = require("nativescript-dev-webpack");
55const nativescriptTarget = require ( "nativescript-dev-webpack/nativescript-target" ) ;
66const CleanWebpackPlugin = require ( "clean-webpack-plugin" ) ;
77const CopyWebpackPlugin = require ( "copy-webpack-plugin" ) ;
8+ const ForkTsCheckerWebpackPlugin = require ( 'fork-ts-checker-webpack-plugin' ) ;
89const { BundleAnalyzerPlugin } = require ( "webpack-bundle-analyzer" ) ;
910const { NativeScriptWorkerPlugin } = require ( "nativescript-worker-loader/NativeScriptWorkerPlugin" ) ;
1011const TerserPlugin = require ( "terser-webpack-plugin" ) ;
@@ -54,6 +55,9 @@ module.exports = env => {
5455 const entryModule = nsWebpack . getEntryModule ( appFullPath , platform ) ;
5556 const entryPath = `.${ sep } ${ entryModule } .ts` ;
5657 const entries = { bundle : entryPath } ;
58+
59+ const tsConfigPath = resolve ( projectRoot , "tsconfig.tns.json" ) ;
60+
5761 if ( platform === "ios" ) {
5862 entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
5963 } ;
@@ -206,7 +210,8 @@ module.exports = env => {
206210 use : {
207211 loader : "ts-loader" ,
208212 options : {
209- configFile : "tsconfig.tns.json" ,
213+ configFile : tsConfigPath ,
214+ transpileOnly : ! ! hmr ,
210215 allowTsInNodeModules : true ,
211216 compilerOptions : {
212217 sourceMap : isAnySourceMapEnabled
@@ -289,6 +294,12 @@ module.exports = env => {
289294
290295 if ( hmr ) {
291296 config . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) ) ;
297+
298+ // With HMR ts-loader should run in `transpileOnly` mode,
299+ // so assure type-checking with fork-ts-checker-webpack-plugin
300+ config . plugins . push ( new ForkTsCheckerWebpackPlugin ( {
301+ tsconfig : tsConfigPath
302+ } ) ) ;
292303 }
293304
294305
0 commit comments