Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 7a036d0

Browse files
committed
Refer to the entry point instead of the first module for default identifier
The order of modules can be reordered by optimize-module-order plugins. The intention is to use the entry point as the default identifier, so refer to entries property of the compilation.
1 parent 6a660f3 commit 7a036d0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/loader.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ export function pitch(request) {
9494
}
9595
try {
9696
let text = this.exec(source, request);
97-
if (typeof text === 'string') { text = [[0, text]]; }
98-
text.forEach((item) => {
99-
const id = item[0];
100-
compilation.modules.forEach((module) => {
101-
if (module.id === id) { item[0] = module.identifier(); }
97+
if (typeof text === 'string') {
98+
text = [[compilation.entries[0].identifier(), text]];
99+
} else {
100+
text.forEach((item) => {
101+
const id = item[0];
102+
compilation.modules.forEach((module) => {
103+
if (module.id === id) { item[0] = module.identifier(); }
104+
});
102105
});
103-
});
106+
}
104107
this[NS](text, query);
105108
if (text.locals && typeof resultSource !== 'undefined') {
106109
resultSource += `\nmodule.exports = ${JSON.stringify(text.locals)};`;

0 commit comments

Comments
 (0)