@@ -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" ) ;
@@ -55,6 +56,9 @@ module.exports = env => {
55
56
const entryModule = nsWebpack . getEntryModule ( appFullPath , platform ) ;
56
57
const entryPath = `.${ sep } ${ entryModule } .ts` ;
57
58
const entries = { bundle : entryPath , application : "./application.android" } ;
59
+
60
+ const tsConfigPath = resolve ( projectRoot , "tsconfig.tns.json" ) ;
61
+
58
62
if ( platform === "ios" ) {
59
63
entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
60
64
} ;
@@ -207,7 +211,8 @@ module.exports = env => {
207
211
use : {
208
212
loader : "ts-loader" ,
209
213
options : {
210
- configFile : "tsconfig.tns.json" ,
214
+ configFile : tsConfigPath ,
215
+ transpileOnly : ! ! hmr ,
211
216
allowTsInNodeModules : true ,
212
217
compilerOptions : {
213
218
sourceMap : isAnySourceMapEnabled
@@ -231,17 +236,7 @@ module.exports = env => {
231
236
{ from : { glob : "**/*.jpg" } } ,
232
237
{ from : { glob : "**/*.png" } } ,
233
238
] , { 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" ) ,
245
240
// For instructions on how to set up workers with webpack
246
241
// check out https://github.com/nativescript/worker-loader
247
242
new NativeScriptWorkerPlugin ( ) ,
@@ -290,6 +285,12 @@ module.exports = env => {
290
285
291
286
if ( hmr ) {
292
287
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
+ } ) ) ;
293
294
}
294
295
295
296
0 commit comments