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

Commit 0b9febe

Browse files
rosen-vladimirovVasil Chimev
authored and
Vasil Chimev
committed
fix(compiler): reject promise with real error (#350)
* fix(compiler): reject promise with real error When the webpack compiler fails, the error is not used in the rejection, so the promise is always rejected with `undefined`. Fix this by respecting the error. Construct real error object as well. * Force rebuild of application when webpack is used In case we want to use webpack, force the build by setting nativeChanged property of changesInfo to true. This is TEMP solution until we have a better one.
1 parent d5eb7b2 commit 0b9febe

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Diff for: lib/before-prepareJS.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ module.exports = function ($mobileHelper, $projectData, hookArgs) {
1010
bundle: appFilesUpdaterOptions.bundle,
1111
watch: false // TODO: Read from CLI options...
1212
};
13-
const result = config.bundle && runWebpackCompiler.bind(runWebpackCompiler, config, $mobileHelper, $projectData);
13+
const result = config.bundle && runWebpackCompiler.bind(runWebpackCompiler, config, $mobileHelper, $projectData, hookArgs);
1414
return result;
1515
}

Diff for: lib/compiler.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ exports.getWebpackProcess = function getWebpackProcess() {
1313
return webpackProcess;
1414
}
1515

16-
exports.runWebpackCompiler = function runWebpackCompiler(config, $mobileHelper, $projectData, originalArgs, originalMethod) {
16+
exports.runWebpackCompiler = function runWebpackCompiler(config, $mobileHelper, $projectData, hookArgs, originalArgs, originalMethod) {
1717
if (config.bundle) {
1818
return new Promise(function (resolveBase, rejectBase) {
19+
if (hookArgs && hookArgs.config && hookArgs.config.changesInfo) {
20+
hookArgs.config.changesInfo.nativeChanged = true;
21+
}
22+
1923
let isResolved = false;
2024
function resolve() {
2125
if (isResolved) return;
@@ -25,13 +29,13 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $mobileHelper,
2529
}
2630
resolveBase();
2731
}
28-
function reject() {
32+
function reject(error) {
2933
if (isResolved) return;
3034
isResolved = true;
3135
if (childProcess) {
3236
childProcess.removeListener("message", resolveOnWebpackCompilationComplete);
3337
}
34-
rejectBase();
38+
rejectBase(error);
3539
}
3640

3741
console.log(`Running webpack for ${config.platform}...`);
@@ -93,10 +97,9 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $mobileHelper,
9397
if (code === 0) {
9498
resolve();
9599
} else {
96-
reject({
97-
code,
98-
message: `child process exited with code ${code}`,
99-
});
100+
const error = new Error(`Executing webpack failed with exit code ${code}.`);
101+
error.code = code;
102+
reject(error);
100103
}
101104
});
102105
});

0 commit comments

Comments
 (0)