fix a bug which causes incorrect providedExports for cached modules

Always update providedExports when they have dependencies

fixes #8455
This commit is contained in:
Tobias Koppers 2018-12-03 21:26:14 +01:00
parent f944002bcd
commit 2f4296e8d9
9 changed files with 30 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class FlagDependencyExportsPlugin {
let module;
let moduleWithExports;
let moduleProvidedExports;
let providedExportsAreTemporary;
const processDependenciesBlock = depBlock => {
for (const dep of depBlock.dependencies) {
@ -72,6 +73,7 @@ class FlagDependencyExportsPlugin {
// store dependencies
const exportDeps = exportDesc.dependencies;
if (exportDeps) {
providedExportsAreTemporary = true;
for (const exportDependency of exportDeps) {
// add dependency for this module
const set = dependencies.get(exportDependency);
@ -96,7 +98,12 @@ class FlagDependencyExportsPlugin {
// Start with all modules without provided exports
for (const module of modules) {
if (!module.buildMeta.providedExports) {
if (module.buildInfo.temporaryProvidedExports) {
// Clear exports when they are temporary
// and recreate them
module.buildMeta.providedExports = null;
queue.enqueue(module);
} else if (!module.buildMeta.providedExports) {
queue.enqueue(module);
}
}
@ -112,7 +119,9 @@ class FlagDependencyExportsPlugin {
)
? new Set(module.buildMeta.providedExports)
: new Set();
providedExportsAreTemporary = false;
processDependenciesBlock(module);
module.buildInfo.temporaryProvidedExports = providedExportsAreTemporary;
if (!moduleWithExports) {
module.buildMeta.providedExports = true;
notifyDependencies();

View File

@ -0,0 +1 @@
export * from "./b";

View File

@ -0,0 +1 @@
export * from "./c";

View File

@ -0,0 +1 @@
export var x0 = "0";

View File

@ -0,0 +1,12 @@
import * as a from "./a";
const nsObj = m => {
Object.defineProperty(m, Symbol.toStringTag, { value: "Module" });
return m;
};
it("should have to correct exports", () => {
expect(a).toEqual(nsObj({
[`x${WATCH_STEP}`]: WATCH_STEP
}));
})

View File

@ -0,0 +1 @@
export var x1 = "1";

View File

@ -0,0 +1 @@
export * from "./c";

View File

@ -0,0 +1 @@
export var x2 = "2";

View File

@ -5823,6 +5823,7 @@ p-try@^1.0.0:
p-try@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1"
integrity sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==
pako@~1.0.5:
version "1.0.6"
@ -6579,6 +6580,7 @@ pump@^2.0.0:
pump@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"