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

fix: do not include hot updates when generating requires in entry files #924

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions plugins/GenerateNativeScriptEntryPointsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
entryChunk = chunk;
} else {
chunk.files.forEach(fileName => {
requireChunkFiles += `require("./${fileName}");`;
if (!this.isHMRFile(fileName)) {
requireChunkFiles += `require("./${fileName}");`;
}
});
}

Expand All @@ -72,8 +74,10 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
throw new Error(`${GenerationFailedError} File "${fileName}" not found for entry "${entryPointName}".`);
}

const currentEntryFileContent = compilation.assets[fileName].source();
compilation.assets[fileName] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
if (!this.isHMRFile(fileName)) {
const currentEntryFileContent = compilation.assets[fileName].source();
compilation.assets[fileName] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
}
});
}

Expand All @@ -84,5 +88,9 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
}
}

GenerateNativeScriptEntryPointsPlugin.prototype.isHMRFile = function (fileName) {
return fileName.indexOf("hot-update") > -1;
}

return GenerateNativeScriptEntryPointsPlugin;
})();