Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 274ff53

Browse files
fix: handle entry points with custom output filename like output.filename: "[name].custom.js"
1 parent 31f6240 commit 274ff53

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

‎plugins/GenerateNativeScriptEntryPointsPlugin.js‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { RawSource } = require("webpack-sources");
22
const { getPackageJson } = require("../projectHelpers");
3-
const { SNAPSHOT_ENTRY_MODULE } = require("./NativeScriptSnapshotPlugin");
3+
const { SNAPSHOT_ENTRY_NAME } = require("./NativeScriptSnapshotPlugin");
44

55
exports.GenerateNativeScriptEntryPointsPlugin = (function () {
66
function GenerateNativeScriptEntryPointsPlugin(appEntryName) {
@@ -39,26 +39,33 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
3939
}
4040

4141
GenerateNativeScriptEntryPointsPlugin.prototype.generateEntryFile = function (compilation, entryPoint) {
42-
const entryPointFileName = `${entryPoint.options.name}.js`;
43-
if (entryPointFileName === SNAPSHOT_ENTRY_MODULE) {
42+
const entryPointName = entryPoint.options.name;
43+
let entryChunk;
44+
if (entryPointName === SNAPSHOT_ENTRY_NAME) {
4445
// Do not require the snapshot entry dependencies as the snapshot will fail.
4546
return;
4647
}
4748

4849
const requireDeps =
4950
entryPoint.chunks.map(chunk => {
5051
let requireChunkFiles = "";
51-
chunk.files.forEach(fileName => {
52-
if (fileName !== entryPointFileName) {
52+
if (chunk.name === entryPointName) {
53+
entryChunk = chunk;
54+
} else {
55+
chunk.files.forEach(fileName => {
5356
requireChunkFiles += `require("./${fileName}");`;
54-
}
55-
});
57+
});
58+
}
5659

5760
return requireChunkFiles;
5861
}).join("\n");
5962

60-
const currentEntryPointContent = compilation.assets[entryPointFileName].source();
61-
compilation.assets[entryPointFileName] = new RawSource(`${requireDeps}${currentEntryPointContent}`);
63+
if (entryChunk) {
64+
entryChunk.files.forEach(fileName => {
65+
const currentEntryFileContent = compilation.assets[fileName].source();
66+
compilation.assets[fileName] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
67+
});
68+
}
6269
}
6370

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

‎plugins/NativeScriptSnapshotPlugin/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const schema = require("./options.json");
1212

1313
const SNAPSHOT_ENTRY_NAME = "snapshot-entry";
1414
const SNAPSHOT_ENTRY_MODULE = `${SNAPSHOT_ENTRY_NAME}.js`;
15-
exports.SNAPSHOT_ENTRY_MODULE = SNAPSHOT_ENTRY_MODULE;
15+
exports.SNAPSHOT_ENTRY_NAME = SNAPSHOT_ENTRY_NAME;
1616

1717
exports.NativeScriptSnapshotPlugin = (function () {
1818
function NativeScriptSnapshotPlugin(options) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /