Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 6e780af

Browse files
committed
fix(inspector_modules): Switch to single runtime chunk
The default setting causes the WebPack runtime to be loaded twice because the `inspector_modules` module is loaded by the iOS runtime as a secondary entry point. This has some undesirable implications as [stated in the documentation](https://webpack.js.org/configuration/optimization/#optimizationruntimechunk): > Imported modules are initialized for each runtime chunk separately, > so if you include multiple entry points on a page, beware of this > behavior. You will probably want to set it to single or use another > configuration that allows you to only have one runtime instance.
1 parent 00ecaa0 commit 6e780af

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

Diff for: templates/webpack.angular.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ module.exports = env => {
140140
},
141141
devtool: sourceMap ? "inline-source-map" : "none",
142142
optimization: {
143+
runtimeChunk: "single",
143144
splitChunks: {
144145
cacheGroups: {
145146
vendor: {
@@ -257,10 +258,16 @@ module.exports = env => {
257258
{ from: { glob: "**/*.png" } },
258259
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
259260
// Generate a bundle starter script and activate it in package.json
260-
new nsWebpack.GenerateBundleStarterPlugin([
261-
"./vendor",
262-
"./bundle",
263-
]),
261+
new nsWebpack.GenerateBundleStarterPlugin(
262+
// Don't include `runtime.js` when creating a snapshot. The plugin
263+
// configures the WebPack runtime to be generated inside the snapshot
264+
// module and no `runtime.js` module exist.
265+
(snapshot ? [] : ["./runtime"])
266+
.concat([
267+
"./vendor",
268+
"./bundle",
269+
])
270+
),
264271
// For instructions on how to set up workers with webpack
265272
// check out https://github.com/nativescript/worker-loader
266273
new NativeScriptWorkerPlugin(),

Diff for: templates/webpack.javascript.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ module.exports = env => {
100100
"__dirname": false,
101101
},
102102
devtool: sourceMap ? "inline-source-map" : "none",
103-
optimization: {
103+
optimization: {
104+
runtimeChunk: "single",
104105
splitChunks: {
105106
cacheGroups: {
106107
vendor: {
@@ -209,10 +210,16 @@ module.exports = env => {
209210
{ from: { glob: "**/*.png" } },
210211
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
211212
// Generate a bundle starter script and activate it in package.json
212-
new nsWebpack.GenerateBundleStarterPlugin([
213-
"./vendor",
214-
"./bundle",
215-
]),
213+
new nsWebpack.GenerateBundleStarterPlugin(
214+
// Don't include `runtime.js` when creating a snapshot. The plugin
215+
// configures the WebPack runtime to be generated inside the snapshot
216+
// module and no `runtime.js` module exist.
217+
(snapshot ? [] : ["./runtime"])
218+
.concat([
219+
"./vendor",
220+
"./bundle",
221+
])
222+
),
216223
// For instructions on how to set up workers with webpack
217224
// check out https://github.com/nativescript/worker-loader
218225
new NativeScriptWorkerPlugin(),

Diff for: templates/webpack.typescript.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ module.exports = env => {
102102
"__dirname": false,
103103
},
104104
devtool: sourceMap ? "inline-source-map" : "none",
105-
optimization: {
105+
optimization: {
106+
runtimeChunk: "single",
106107
splitChunks: {
107108
cacheGroups: {
108109
vendor: {
@@ -222,10 +223,16 @@ module.exports = env => {
222223
{ from: { glob: "**/*.png" } },
223224
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
224225
// Generate a bundle starter script and activate it in package.json
225-
new nsWebpack.GenerateBundleStarterPlugin([
226-
"./vendor",
227-
"./bundle",
228-
]),
226+
new nsWebpack.GenerateBundleStarterPlugin(
227+
// Don't include `runtime.js` when creating a snapshot. The plugin
228+
// configures the WebPack runtime to be generated inside the snapshot
229+
// module and no `runtime.js` module exist.
230+
(snapshot ? [] : ["./runtime"])
231+
.concat([
232+
"./vendor",
233+
"./bundle",
234+
])
235+
),
229236
// For instructions on how to set up workers with webpack
230237
// check out https://github.com/nativescript/worker-loader
231238
new NativeScriptWorkerPlugin(),

Diff for: templates/webpack.vue.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ module.exports = env => {
113113
},
114114
devtool: "none",
115115
optimization: {
116+
runtimeChunk: "single",
116117
splitChunks: {
117118
cacheGroups: {
118119
vendor: {
@@ -229,10 +230,16 @@ module.exports = env => {
229230
{ from: { glob: "assets/**/*" } },
230231
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
231232
// Generate a bundle starter script and activate it in package.json
232-
new nsWebpack.GenerateBundleStarterPlugin([
233-
"./vendor",
234-
"./bundle",
235-
]),
233+
new nsWebpack.GenerateBundleStarterPlugin(
234+
// Don't include `runtime.js` when creating a snapshot. The plugin
235+
// configures the WebPack runtime to be generated inside the snapshot
236+
// module and no `runtime.js` module exist.
237+
(snapshot ? [] : ["./runtime"])
238+
.concat([
239+
"./vendor",
240+
"./bundle",
241+
])
242+
),
236243
// For instructions on how to set up workers with webpack
237244
// check out https://github.com/nativescript/worker-loader
238245
new NativeScriptWorkerPlugin(),

0 commit comments

Comments
 (0)