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

Commit 3aef461

Browse files
committed
fix: throw errors when the compilation state is not valid in order to make the investigation easier
1 parent 23675a4 commit 3aef461

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

plugins/GenerateNativeScriptEntryPointsPlugin.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ const { RawSource } = require("webpack-sources");
22
const { getPackageJson } = require("../projectHelpers");
33
const { SNAPSHOT_ENTRY_NAME } = require("./NativeScriptSnapshotPlugin");
44

5+
56
exports.GenerateNativeScriptEntryPointsPlugin = (function () {
7+
const GenerationFailedError = "Unable to generate entry files.";
8+
69
function GenerateNativeScriptEntryPointsPlugin(appEntryName) {
710
this.appEntryName = appEntryName;
811
this.files = {};
@@ -60,12 +63,18 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
6063
return requireChunkFiles;
6164
}).join("");
6265

63-
if (entryChunk) {
64-
entryChunk.files.forEach(fileName => {
65-
const currentEntryFileContent = compilation.assets[fileName].source();
66-
compilation.assets[fileName] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
67-
});
66+
if (!entryChunk) {
67+
throw new Error(`${GenerationFailedError} Entry chunk not found for entry "${entryPointName}".`);
6868
}
69+
70+
entryChunk.files.forEach(fileName => {
71+
if (!compilation.assets[fileName]) {
72+
throw new Error(`${GenerationFailedError} File "${fileName}" not found for entry "${entryPointName}".`);
73+
}
74+
75+
const currentEntryFileContent = compilation.assets[fileName].source();
76+
compilation.assets[fileName] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
77+
});
6978
}
7079

7180
GenerateNativeScriptEntryPointsPlugin.prototype.addAsset = function (compilation, name, content) {

0 commit comments

Comments
 (0)