Skip to content

Commit

Permalink
Merge pull request #8457 from webpack/bugfix/rebuild-provided-exports
Browse files Browse the repository at this point in the history
fix a bug which causes incorrect providedExports for cached modules
  • Loading branch information
sokra committed Dec 4, 2018
2 parents f944002 + 2f4296e commit 96f625c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/FlagDependencyExportsPlugin.js
Expand Up @@ -32,6 +32,7 @@ class FlagDependencyExportsPlugin {
let module;
let moduleWithExports;
let moduleProvidedExports;
let providedExportsAreTemporary;

const processDependenciesBlock = depBlock => {
for (const dep of depBlock.dependencies) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/watchCases/parsing/reexport-chain/0/a.js
@@ -0,0 +1 @@
export * from "./b";
1 change: 1 addition & 0 deletions test/watchCases/parsing/reexport-chain/0/b.js
@@ -0,0 +1 @@
export * from "./c";
1 change: 1 addition & 0 deletions test/watchCases/parsing/reexport-chain/0/c.js
@@ -0,0 +1 @@
export var x0 = "0";
12 changes: 12 additions & 0 deletions test/watchCases/parsing/reexport-chain/0/index.js
@@ -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
}));
})
1 change: 1 addition & 0 deletions test/watchCases/parsing/reexport-chain/1/c.js
@@ -0,0 +1 @@
export var x1 = "1";
1 change: 1 addition & 0 deletions test/watchCases/parsing/reexport-chain/2/a.js
@@ -0,0 +1 @@
export * from "./c";
1 change: 1 addition & 0 deletions test/watchCases/parsing/reexport-chain/2/c.js
@@ -0,0 +1 @@
export var x2 = "2";
2 changes: 2 additions & 0 deletions yarn.lock
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 96f625c

Please sign in to comment.