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

Commit 3698cb7

Browse files
committed
fix-next: pass --env.hmr only if the --hmr flag is raised (#651)
1 parent 529b2bf commit 3698cb7

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

lib/before-prepareJS.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ const { runWebpackCompiler } = require("./compiler");
22

33
module.exports = function ($logger, $liveSyncService, $options, hookArgs) {
44
const env = hookArgs.config.env || {};
5-
env.hmr = !!$options.hmr;
5+
if ($options.hmr) {
6+
env.hmr = true;
7+
}
8+
69
const platform = hookArgs.config.platform;
710
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
811
const config = {

lib/before-watch.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
const { getWebpackProcesses, runWebpackCompiler, stopWebpackCompiler } = require("./compiler");
22

33
module.exports = function ($logger, $liveSyncService, $options, $devicesService, hookArgs) {
4-
if (hookArgs.config) {
5-
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
6-
if (appFilesUpdaterOptions.bundle) {
7-
$liveSyncService.on("liveSyncStopped", data => {
8-
const webpackProcesses = getWebpackProcesses();
9-
Object.keys(webpackProcesses).forEach(platform => {
10-
const devices = $devicesService.getDevicesForPlatform(platform);
11-
if (!devices || !devices.length) {
12-
stopWebpackCompiler(platform);
13-
}
14-
});
15-
});
4+
if (hookArgs.config) {
5+
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
6+
if (appFilesUpdaterOptions.bundle) {
7+
$liveSyncService.on("liveSyncStopped", data => {
8+
const webpackProcesses = getWebpackProcesses();
9+
Object.keys(webpackProcesses).forEach(platform => {
10+
const devices = $devicesService.getDevicesForPlatform(platform);
11+
if (!devices || !devices.length) {
12+
stopWebpackCompiler(platform);
13+
}
14+
});
15+
});
1616

17-
const platforms = hookArgs.config.platforms;
18-
return Promise.all(platforms.map(platform => {
19-
const env = hookArgs.config.env || {};
20-
env.hmr = !!$options.hmr;
21-
const config = {
22-
env,
23-
platform,
24-
bundle: appFilesUpdaterOptions.bundle,
25-
release: appFilesUpdaterOptions.release,
26-
watch: true
27-
};
17+
const platforms = hookArgs.config.platforms;
18+
return Promise.all(platforms.map(platform => {
19+
const env = hookArgs.config.env || {};
20+
if ($options.hmr) {
21+
env.hmr = true;
22+
}
23+
const config = {
24+
env,
25+
platform,
26+
bundle: appFilesUpdaterOptions.bundle,
27+
release: appFilesUpdaterOptions.release,
28+
watch: true
29+
};
2830

29-
return runWebpackCompiler(config, hookArgs.projectData, $logger, $liveSyncService, hookArgs);
30-
}));
31-
}
32-
}
31+
return runWebpackCompiler(config, hookArgs.projectData, $logger, $liveSyncService, hookArgs);
32+
}));
33+
}
34+
}
3335
}

lib/compiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ function buildEnvCommandLineParams(config, envData, $logger) {
135135
const args = [];
136136
envFlagNames.map(item => {
137137
let envValue = envData[item];
138-
if(!Array.isArray(envValue)) {
138+
if (!Array.isArray(envValue)) {
139139
envValue = [envValue];
140140
}
141141
envValue.map(value => args.push(`--env.${item}=${value}`))
142142
});
143-
143+
144144
return args;
145145
}
146146

0 commit comments

Comments
 (0)