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

Commit 9bb7ec3

Browse files
Merge remote-tracking branch 'origin/master' into svetoslavtsenov/merge-release-in-master
2 parents 968551b + f476c56 commit 9bb7ec3

11 files changed

+165
-75
lines changed

Diff for: CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
<a name="0.20.0"></a>
35-
# [0.20.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.18.3...0.20.0) (2019-02-08)
35+
# [0.20.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.19.2...0.20.0) (2019-02-08)
3636

3737

3838
### Bug Fixes

Diff for: lib/compiler.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ function logSnapshotWarningMessage($logger) {
174174
function stopWebpackForPlatform($logger, platform) {
175175
$logger.trace(`Stopping webpack watch for platform ${platform}.`);
176176
const webpackProcess = webpackProcesses[platform];
177-
webpackProcess.kill("SIGINT");
178-
179-
delete webpackProcesses[platform];
177+
if (webpackProcess) {
178+
webpackProcess.kill("SIGINT");
179+
delete webpackProcesses[platform];
180+
}
180181
}
181182

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-dev-webpack",
3-
"version": "0.20.3",
3+
"version": "0.21.0",
44
"main": "index",
55
"description": "",
66
"homepage": "http://www.telerik.com",

Diff for: templates/webpack.angular.js

+29-15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ module.exports = env => {
5555
const tsConfigName = "tsconfig.tns.json";
5656
const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`;
5757
const entryPath = `.${sep}${entryModule}`;
58+
const entries = { bundle: entryPath };
59+
if (platform === "ios") {
60+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
61+
};
62+
5863
const ngCompilerTransformers = [];
5964
const additionalLazyModuleResources = [];
6065
if (aot) {
@@ -101,9 +106,7 @@ module.exports = env => {
101106
]
102107
},
103108
target: nativescriptTarget,
104-
entry: {
105-
bundle: entryPath,
106-
},
109+
entry: entries,
107110
output: {
108111
pathinfo: false,
109112
path: dist,
@@ -139,6 +142,7 @@ module.exports = env => {
139142
},
140143
devtool: sourceMap ? "inline-source-map" : "none",
141144
optimization: {
145+
runtimeChunk: "single",
142146
splitChunks: {
143147
cacheGroups: {
144148
vendor: {
@@ -241,25 +245,23 @@ module.exports = env => {
241245
}),
242246
// Remove all files from the out dir.
243247
new CleanWebpackPlugin([`${dist}/**/*`]),
244-
// Copy native app resources to out dir.
245-
new CopyWebpackPlugin([
246-
{
247-
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
248-
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
249-
context: projectRoot
250-
},
251-
]),
252248
// Copy assets to out dir. Add your own globs as needed.
253249
new CopyWebpackPlugin([
254250
{ from: { glob: "fonts/**" } },
255251
{ from: { glob: "**/*.jpg" } },
256252
{ from: { glob: "**/*.png" } },
257253
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
258254
// Generate a bundle starter script and activate it in package.json
259-
new nsWebpack.GenerateBundleStarterPlugin([
260-
"./vendor",
261-
"./bundle",
262-
]),
255+
new nsWebpack.GenerateBundleStarterPlugin(
256+
// Don't include `runtime.js` when creating a snapshot. The plugin
257+
// configures the WebPack runtime to be generated inside the snapshot
258+
// module and no `runtime.js` module exist.
259+
(snapshot ? [] : ["./runtime"])
260+
.concat([
261+
"./vendor",
262+
"./bundle",
263+
])
264+
),
263265
// For instructions on how to set up workers with webpack
264266
// check out https://github.com/nativescript/worker-loader
265267
new NativeScriptWorkerPlugin(),
@@ -269,6 +271,18 @@ module.exports = env => {
269271
],
270272
};
271273

274+
// Copy the native app resources to the out dir
275+
// only if doing a full build (tns run/build) and not previewing (tns preview)
276+
if (!externals || externals.length === 0) {
277+
config.plugins.push(new CopyWebpackPlugin([
278+
{
279+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
280+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
281+
context: projectRoot
282+
},
283+
]));
284+
}
285+
272286

273287
if (report) {
274288
// Generate report files for bundles content

Diff for: templates/webpack.config.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ describe('webpack.config.js', () => {
8383
});
8484

8585
it('returns empty array when externals are not passed', () => {
86-
const config = webpackConfig(getInput({ platform }));
86+
const input = getInput({ platform });
87+
const config = webpackConfig(input);
8788
expect(config.externals).toEqual([]);
8889
});
8990

Diff for: templates/webpack.javascript.js

+29-16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ module.exports = env => {
5050

5151
const entryModule = nsWebpack.getEntryModule(appFullPath);
5252
const entryPath = `.${sep}${entryModule}.js`;
53+
const entries = { bundle: entryPath };
54+
if (platform === "ios") {
55+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
56+
};
5357

5458
const config = {
5559
mode: uglify ? "production" : "development",
@@ -63,9 +67,7 @@ module.exports = env => {
6367
]
6468
},
6569
target: nativescriptTarget,
66-
entry: {
67-
bundle: entryPath,
68-
},
70+
entry: entries,
6971
output: {
7072
pathinfo: false,
7173
path: dist,
@@ -100,7 +102,8 @@ module.exports = env => {
100102
"__dirname": false,
101103
},
102104
devtool: sourceMap ? "inline-source-map" : "none",
103-
optimization: {
105+
optimization: {
106+
runtimeChunk: "single",
104107
splitChunks: {
105108
cacheGroups: {
106109
vendor: {
@@ -194,25 +197,23 @@ module.exports = env => {
194197
}),
195198
// Remove all files from the out dir.
196199
new CleanWebpackPlugin([ `${dist}/**/*` ]),
197-
// Copy native app resources to out dir.
198-
new CopyWebpackPlugin([
199-
{
200-
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
201-
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
202-
context: projectRoot
203-
},
204-
]),
205200
// Copy assets to out dir. Add your own globs as needed.
206201
new CopyWebpackPlugin([
207202
{ from: { glob: "fonts/**" } },
208203
{ from: { glob: "**/*.jpg" } },
209204
{ from: { glob: "**/*.png" } },
210205
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
211206
// Generate a bundle starter script and activate it in package.json
212-
new nsWebpack.GenerateBundleStarterPlugin([
213-
"./vendor",
214-
"./bundle",
215-
]),
207+
new nsWebpack.GenerateBundleStarterPlugin(
208+
// Don't include `runtime.js` when creating a snapshot. The plugin
209+
// configures the WebPack runtime to be generated inside the snapshot
210+
// module and no `runtime.js` module exist.
211+
(snapshot ? [] : ["./runtime"])
212+
.concat([
213+
"./vendor",
214+
"./bundle",
215+
])
216+
),
216217
// For instructions on how to set up workers with webpack
217218
// check out https://github.com/nativescript/worker-loader
218219
new NativeScriptWorkerPlugin(),
@@ -225,6 +226,18 @@ module.exports = env => {
225226
],
226227
};
227228

229+
// Copy the native app resources to the out dir
230+
// only if doing a full build (tns run/build) and not previewing (tns preview)
231+
if (!externals || externals.length === 0) {
232+
config.plugins.push(new CopyWebpackPlugin([
233+
{
234+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
235+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
236+
context: projectRoot
237+
},
238+
]));
239+
}
240+
228241
if (report) {
229242
// Generate report files for bundles content
230243
config.plugins.push(new BundleAnalyzerPlugin({

Diff for: templates/webpack.typescript.js

+29-16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ module.exports = env => {
5050

5151
const entryModule = nsWebpack.getEntryModule(appFullPath);
5252
const entryPath = `.${sep}${entryModule}.ts`;
53+
const entries = { bundle: entryPath };
54+
if (platform === "ios") {
55+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
56+
};
5357

5458
const config = {
5559
mode: uglify ? "production" : "development",
@@ -63,9 +67,7 @@ module.exports = env => {
6367
]
6468
},
6569
target: nativescriptTarget,
66-
entry: {
67-
bundle: entryPath,
68-
},
70+
entry: entries,
6971
output: {
7072
pathinfo: false,
7173
path: dist,
@@ -102,7 +104,8 @@ module.exports = env => {
102104
"__dirname": false,
103105
},
104106
devtool: sourceMap ? "inline-source-map" : "none",
105-
optimization: {
107+
optimization: {
108+
runtimeChunk: "single",
106109
splitChunks: {
107110
cacheGroups: {
108111
vendor: {
@@ -207,25 +210,23 @@ module.exports = env => {
207210
}),
208211
// Remove all files from the out dir.
209212
new CleanWebpackPlugin([ `${dist}/**/*` ]),
210-
// Copy native app resources to out dir.
211-
new CopyWebpackPlugin([
212-
{
213-
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
214-
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
215-
context: projectRoot
216-
},
217-
]),
218213
// Copy assets to out dir. Add your own globs as needed.
219214
new CopyWebpackPlugin([
220215
{ from: { glob: "fonts/**" } },
221216
{ from: { glob: "**/*.jpg" } },
222217
{ from: { glob: "**/*.png" } },
223218
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
224219
// Generate a bundle starter script and activate it in package.json
225-
new nsWebpack.GenerateBundleStarterPlugin([
226-
"./vendor",
227-
"./bundle",
228-
]),
220+
new nsWebpack.GenerateBundleStarterPlugin(
221+
// Don't include `runtime.js` when creating a snapshot. The plugin
222+
// configures the WebPack runtime to be generated inside the snapshot
223+
// module and no `runtime.js` module exist.
224+
(snapshot ? [] : ["./runtime"])
225+
.concat([
226+
"./vendor",
227+
"./bundle",
228+
])
229+
),
229230
// For instructions on how to set up workers with webpack
230231
// check out https://github.com/nativescript/worker-loader
231232
new NativeScriptWorkerPlugin(),
@@ -238,6 +239,18 @@ module.exports = env => {
238239
],
239240
};
240241

242+
// Copy the native app resources to the out dir
243+
// only if doing a full build (tns run/build) and not previewing (tns preview)
244+
if (!externals || externals.length === 0) {
245+
config.plugins.push(new CopyWebpackPlugin([
246+
{
247+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
248+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
249+
context: projectRoot
250+
},
251+
]));
252+
}
253+
241254
if (report) {
242255
// Generate report files for bundles content
243256
config.plugins.push(new BundleAnalyzerPlugin({

Diff for: templates/webpack.vue.js

+28-13
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ module.exports = env => {
5757

5858
const entryModule = nsWebpack.getEntryModule(appFullPath);
5959
const entryPath = `.${sep}${entryModule}`;
60+
const entries = { bundle: entryPath };
61+
if (platform === "ios") {
62+
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
63+
};
6064
console.log(`Bundling application for entryPath ${entryPath}...`);
6165

6266
const config = {
@@ -72,9 +76,7 @@ module.exports = env => {
7276
},
7377
target: nativescriptTarget,
7478
// target: nativeScriptVueTarget,
75-
entry: {
76-
bundle: entryPath,
77-
},
79+
entry: entries,
7880
output: {
7981
pathinfo: false,
8082
path: dist,
@@ -114,6 +116,7 @@ module.exports = env => {
114116
},
115117
devtool: sourceMap ? "inline-source-map" : "none",
116118
optimization: {
119+
runtimeChunk: "single",
117120
splitChunks: {
118121
cacheGroups: {
119122
vendor: {
@@ -217,23 +220,23 @@ module.exports = env => {
217220
}),
218221
// Remove all files from the out dir.
219222
new CleanWebpackPlugin([`${dist}/**/*`]),
220-
// Copy native app resources to out dir.
221-
new CopyWebpackPlugin([{
222-
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
223-
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
224-
context: projectRoot,
225-
}]),
226223
// Copy assets to out dir. Add your own globs as needed.
227224
new CopyWebpackPlugin([
228225
{ from: { glob: "fonts/**" } },
229226
{ from: { glob: "**/*.+(jpg|png)" } },
230227
{ from: { glob: "assets/**/*" } },
231228
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
232229
// Generate a bundle starter script and activate it in package.json
233-
new nsWebpack.GenerateBundleStarterPlugin([
234-
"./vendor",
235-
"./bundle",
236-
]),
230+
new nsWebpack.GenerateBundleStarterPlugin(
231+
// Don't include `runtime.js` when creating a snapshot. The plugin
232+
// configures the WebPack runtime to be generated inside the snapshot
233+
// module and no `runtime.js` module exist.
234+
(snapshot ? [] : ["./runtime"])
235+
.concat([
236+
"./vendor",
237+
"./bundle",
238+
])
239+
),
237240
// For instructions on how to set up workers with webpack
238241
// check out https://github.com/nativescript/worker-loader
239242
new NativeScriptWorkerPlugin(),
@@ -246,6 +249,18 @@ module.exports = env => {
246249
],
247250
};
248251

252+
// Copy the native app resources to the out dir
253+
// only if doing a full build (tns run/build) and not previewing (tns preview)
254+
if (!externals || externals.length === 0) {
255+
config.plugins.push(new CopyWebpackPlugin([
256+
{
257+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
258+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
259+
context: projectRoot
260+
},
261+
]));
262+
}
263+
249264
if (report) {
250265
// Generate report files for bundles content
251266
config.plugins.push(new BundleAnalyzerPlugin({

0 commit comments

Comments
 (0)