@@ -5,6 +5,7 @@ const nsWebpack = require("nativescript-dev-webpack");
5
5
const nativescriptTarget = require ( "nativescript-dev-webpack/nativescript-target" ) ;
6
6
const CleanWebpackPlugin = require ( "clean-webpack-plugin" ) ;
7
7
const CopyWebpackPlugin = require ( "copy-webpack-plugin" ) ;
8
+ const ForkTsCheckerWebpackPlugin = require ( 'fork-ts-checker-webpack-plugin' ) ;
8
9
const { BundleAnalyzerPlugin } = require ( "webpack-bundle-analyzer" ) ;
9
10
const { NativeScriptWorkerPlugin } = require ( "nativescript-worker-loader/NativeScriptWorkerPlugin" ) ;
10
11
const TerserPlugin = require ( "terser-webpack-plugin" ) ;
@@ -54,6 +55,9 @@ module.exports = env => {
54
55
const entryModule = nsWebpack . getEntryModule ( appFullPath , platform ) ;
55
56
const entryPath = `.${ sep } ${ entryModule } .ts` ;
56
57
const entries = { bundle : entryPath } ;
58
+
59
+ const tsConfigPath = resolve ( projectRoot , "tsconfig.tns.json" ) ;
60
+
57
61
if ( platform === "ios" ) {
58
62
entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
59
63
} ;
@@ -206,7 +210,8 @@ module.exports = env => {
206
210
use : {
207
211
loader : "ts-loader" ,
208
212
options : {
209
- configFile : "tsconfig.tns.json" ,
213
+ configFile : tsConfigPath ,
214
+ transpileOnly : ! ! hmr ,
210
215
allowTsInNodeModules : true ,
211
216
compilerOptions : {
212
217
sourceMap : isAnySourceMapEnabled
@@ -289,6 +294,12 @@ module.exports = env => {
289
294
290
295
if ( hmr ) {
291
296
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
+ } ) ) ;
292
303
}
293
304
294
305
0 commit comments