mirror of https://github.com/webpack/webpack.git
test and fix persistent caching
This commit is contained in:
parent
e78a76b2e0
commit
cbb7ffc94d
|
@ -24,6 +24,19 @@ class FallbackDependency extends Dependency {
|
||||||
get type() {
|
get type() {
|
||||||
return "fallbacks";
|
return "fallbacks";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serialize(context) {
|
||||||
|
const { write } = context;
|
||||||
|
write(this.requests);
|
||||||
|
super.serialize(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static deserialize(context) {
|
||||||
|
const { read } = context;
|
||||||
|
const obj = new FallbackDependency(read());
|
||||||
|
obj.deserialize(context);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
makeSerializable(
|
makeSerializable(
|
||||||
|
|
|
@ -175,12 +175,12 @@ class ConsumeSharedPlugin {
|
||||||
}
|
}
|
||||||
const match = unresolvedConsumes.get(request);
|
const match = unresolvedConsumes.get(request);
|
||||||
if (match !== undefined) {
|
if (match !== undefined) {
|
||||||
return new ConsumeSharedModule(context, match);
|
return new ConsumeSharedModule(compiler.context, match);
|
||||||
}
|
}
|
||||||
for (const [prefix, options] of prefixConsumes) {
|
for (const [prefix, options] of prefixConsumes) {
|
||||||
if (request.startsWith(prefix)) {
|
if (request.startsWith(prefix)) {
|
||||||
const remainder = request.slice(prefix.length);
|
const remainder = request.slice(prefix.length);
|
||||||
return new ConsumeSharedModule(context, {
|
return new ConsumeSharedModule(compiler.context, {
|
||||||
...options,
|
...options,
|
||||||
import: options.import
|
import: options.import
|
||||||
? options.import + remainder
|
? options.import + remainder
|
||||||
|
@ -202,7 +202,7 @@ class ConsumeSharedPlugin {
|
||||||
}
|
}
|
||||||
const options = resolvedConsumes.get(createData.resource);
|
const options = resolvedConsumes.get(createData.resource);
|
||||||
if (options !== undefined) {
|
if (options !== undefined) {
|
||||||
return new ConsumeSharedModule(context, options);
|
return new ConsumeSharedModule(compiler.context, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,6 +54,8 @@ describe("Persistent Caching", () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
webpack({ ...config, ...configAdditions }, (err, stats) => {
|
webpack({ ...config, ...configAdditions }, (err, stats) => {
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
|
if (stats.hasErrors())
|
||||||
|
return reject(stats.toString({ preset: "errors-only" }));
|
||||||
resolve(stats);
|
resolve(stats);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -138,7 +140,8 @@ export default ${files.map((_, i) => `f${i}`).join(" + ")};
|
||||||
const data = {
|
const data = {
|
||||||
"index.js":
|
"index.js":
|
||||||
"export default import('container/src/exposed').then(m => m.default);",
|
"export default import('container/src/exposed').then(m => m.default);",
|
||||||
"exposed.js": "export default 42;"
|
"exposed.js": "import lib from 'lib'; export default 21 + lib;",
|
||||||
|
"lib.js": "export default 21"
|
||||||
};
|
};
|
||||||
await updateSrc(data);
|
await updateSrc(data);
|
||||||
const configAdditions = {
|
const configAdditions = {
|
||||||
|
@ -148,7 +151,15 @@ export default ${files.map((_, i) => `f${i}`).join(" + ")};
|
||||||
library: { type: "commonjs-module" },
|
library: { type: "commonjs-module" },
|
||||||
exposes: ["./src/exposed"],
|
exposes: ["./src/exposed"],
|
||||||
remotes: {
|
remotes: {
|
||||||
container: "./container"
|
container: ["./no-container", "./container"]
|
||||||
|
},
|
||||||
|
shared: {
|
||||||
|
lib: {
|
||||||
|
import: "./src/lib",
|
||||||
|
shareKey: "lib",
|
||||||
|
version: "1.2.3",
|
||||||
|
requiredVersion: "^1.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue