diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index e8de5173..f5a97343 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -54,6 +54,11 @@ module.exports = env => { const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`; const entryPath = `.${sep}${entryModule}`; + const entries = { bundle: entryPath }; + if (platform === "ios") { + entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js"; + }; + const ngCompilerTransformers = []; const additionalLazyModuleResources = []; if (aot) { @@ -100,9 +105,7 @@ module.exports = env => { ] }, target: nativescriptTarget, - entry: { - bundle: entryPath, - }, + entry: entries, output: { pathinfo: false, path: dist, @@ -137,6 +140,7 @@ module.exports = env => { }, devtool: sourceMap ? "inline-source-map" : "none", optimization: { + runtimeChunk: "single", splitChunks: { cacheGroups: { vendor: { @@ -254,10 +258,16 @@ module.exports = env => { { from: { glob: "**/*.png" } }, ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./bundle", - ]), + new nsWebpack.GenerateBundleStarterPlugin( + // Don't include `runtime.js` when creating a snapshot. The plugin + // configures the WebPack runtime to be generated inside the snapshot + // module and no `runtime.js` module exist. + (snapshot ? [] : ["./runtime"]) + .concat([ + "./vendor", + "./bundle", + ]) + ), // For instructions on how to set up workers with webpack // check out https://github.com/nativescript/worker-loader new NativeScriptWorkerPlugin(), diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index 780e9ecd..b2b6d3fa 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -49,6 +49,10 @@ module.exports = env => { const entryModule = nsWebpack.getEntryModule(appFullPath); const entryPath = `.${sep}${entryModule}.js`; + const entries = { bundle: entryPath }; + if (platform === "ios") { + entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js"; + }; const config = { mode: uglify ? "production" : "development", @@ -62,9 +66,7 @@ module.exports = env => { ] }, target: nativescriptTarget, - entry: { - bundle: entryPath, - }, + entry: entries, output: { pathinfo: false, path: dist, @@ -98,7 +100,8 @@ module.exports = env => { "__dirname": false, }, devtool: sourceMap ? "inline-source-map" : "none", - optimization: { + optimization: { + runtimeChunk: "single", splitChunks: { cacheGroups: { vendor: { @@ -207,10 +210,16 @@ module.exports = env => { { from: { glob: "**/*.png" } }, ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./bundle", - ]), + new nsWebpack.GenerateBundleStarterPlugin( + // Don't include `runtime.js` when creating a snapshot. The plugin + // configures the WebPack runtime to be generated inside the snapshot + // module and no `runtime.js` module exist. + (snapshot ? [] : ["./runtime"]) + .concat([ + "./vendor", + "./bundle", + ]) + ), // For instructions on how to set up workers with webpack // check out https://github.com/nativescript/worker-loader new NativeScriptWorkerPlugin(), diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 913977c9..8f970251 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -49,6 +49,10 @@ module.exports = env => { const entryModule = nsWebpack.getEntryModule(appFullPath); const entryPath = `.${sep}${entryModule}.ts`; + const entries = { bundle: entryPath }; + if (platform === "ios") { + entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js"; + }; const config = { mode: uglify ? "production" : "development", @@ -62,9 +66,7 @@ module.exports = env => { ] }, target: nativescriptTarget, - entry: { - bundle: entryPath, - }, + entry: entries, output: { pathinfo: false, path: dist, @@ -100,7 +102,8 @@ module.exports = env => { "__dirname": false, }, devtool: sourceMap ? "inline-source-map" : "none", - optimization: { + optimization: { + runtimeChunk: "single", splitChunks: { cacheGroups: { vendor: { @@ -220,10 +223,16 @@ module.exports = env => { { from: { glob: "**/*.png" } }, ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./bundle", - ]), + new nsWebpack.GenerateBundleStarterPlugin( + // Don't include `runtime.js` when creating a snapshot. The plugin + // configures the WebPack runtime to be generated inside the snapshot + // module and no `runtime.js` module exist. + (snapshot ? [] : ["./runtime"]) + .concat([ + "./vendor", + "./bundle", + ]) + ), // For instructions on how to set up workers with webpack // check out https://github.com/nativescript/worker-loader new NativeScriptWorkerPlugin(), diff --git a/templates/webpack.vue.js b/templates/webpack.vue.js index 18a09ff3..def82f1a 100644 --- a/templates/webpack.vue.js +++ b/templates/webpack.vue.js @@ -55,6 +55,10 @@ module.exports = env => { const entryModule = nsWebpack.getEntryModule(appFullPath); const entryPath = `.${sep}${entryModule}`; + const entries = { bundle: entryPath }; + if (platform === "ios") { + entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js"; + }; console.log(`Bundling application for entryPath ${entryPath}...`); const config = { @@ -70,9 +74,7 @@ module.exports = env => { }, target: nativescriptTarget, // target: nativeScriptVueTarget, - entry: { - bundle: entryPath, - }, + entry: entries, output: { pathinfo: false, path: dist, @@ -111,6 +113,7 @@ module.exports = env => { }, devtool: "none", optimization: { + runtimeChunk: "single", splitChunks: { cacheGroups: { vendor: { @@ -227,10 +230,16 @@ module.exports = env => { { from: { glob: "assets/**/*" } }, ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./bundle", - ]), + new nsWebpack.GenerateBundleStarterPlugin( + // Don't include `runtime.js` when creating a snapshot. The plugin + // configures the WebPack runtime to be generated inside the snapshot + // module and no `runtime.js` module exist. + (snapshot ? [] : ["./runtime"]) + .concat([ + "./vendor", + "./bundle", + ]) + ), // For instructions on how to set up workers with webpack // check out https://github.com/nativescript/worker-loader new NativeScriptWorkerPlugin(),