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

Commit

Permalink
Refer to the entry point instead of the first module for default iden…
Browse files Browse the repository at this point in the history
…tifier

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.
  • Loading branch information
akihikodaki committed Aug 14, 2017
1 parent 6a660f3 commit 7a036d0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/loader.js
Expand Up @@ -94,13 +94,16 @@ export function pitch(request) {
}
try {
let text = this.exec(source, request);
if (typeof text === 'string') { text = [[0, text]]; }
text.forEach((item) => {
const id = item[0];
compilation.modules.forEach((module) => {
if (module.id === id) { item[0] = module.identifier(); }
if (typeof text === 'string') {
text = [[compilation.entries[0].identifier(), text]];
} else {
text.forEach((item) => {
const id = item[0];
compilation.modules.forEach((module) => {
if (module.id === id) { item[0] = module.identifier(); }
});
});
});
}
this[NS](text, query);
if (text.locals && typeof resultSource !== 'undefined') {
resultSource += `\nmodule.exports = ${JSON.stringify(text.locals)};`;
Expand Down

0 comments on commit 7a036d0

Please sign in to comment.