@@ -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" ) ;
@@ -55,6 +56,9 @@ module.exports = env => {
5556 const entryModule = nsWebpack . getEntryModule ( appFullPath , platform ) ;
5657 const entryPath = `.${ sep } ${ entryModule } .ts` ;
5758 const entries = { bundle : entryPath , application : "./application.android" } ;
59+
60+ const tsConfigPath = resolve ( projectRoot , "tsconfig.tns.json" ) ;
61+
5862 if ( platform === "ios" ) {
5963 entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
6064 } ;
@@ -207,7 +211,8 @@ module.exports = env => {
207211 use : {
208212 loader : "ts-loader" ,
209213 options : {
210- configFile : "tsconfig.tns.json" ,
214+ configFile : tsConfigPath ,
215+ transpileOnly : ! ! hmr ,
211216 allowTsInNodeModules : true ,
212217 compilerOptions : {
213218 sourceMap : isAnySourceMapEnabled
@@ -231,17 +236,7 @@ module.exports = env => {
231236 { from : { glob : "**/*.jpg" } } ,
232237 { from : { glob : "**/*.png" } } ,
233238 ] , { ignore : [ `${ relative ( appPath , appResourcesFullPath ) } /**` ] } ) ,
234- // Generate a bundle starter script and activate it in package.json
235- new nsWebpack . GenerateBundleStarterPlugin (
236- // Don't include `runtime.js` when creating a snapshot. The plugin
237- // configures the WebPack runtime to be generated inside the snapshot
238- // module and no `runtime.js` module exist.
239- ( snapshot ? [ ] : [ "./runtime" ] )
240- . concat ( [
241- "./vendor" ,
242- "./bundle" ,
243- ] )
244- ) ,
239+ new nsWebpack . GenerateNativeScriptEntryPointsPlugin ( "bundle" ) ,
245240 // For instructions on how to set up workers with webpack
246241 // check out https://github.com/nativescript/worker-loader
247242 new NativeScriptWorkerPlugin ( ) ,
@@ -290,6 +285,12 @@ module.exports = env => {
290285
291286 if ( hmr ) {
292287 config . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) ) ;
288+
289+ // With HMR ts-loader should run in `transpileOnly` mode,
290+ // so assure type-checking with fork-ts-checker-webpack-plugin
291+ config . plugins . push ( new ForkTsCheckerWebpackPlugin ( {
292+ tsconfig : tsConfigPath
293+ } ) ) ;
293294 }
294295
295296
0 commit comments