mirror of https://github.com/webpack/webpack.git
test: added
This commit is contained in:
parent
c5eccb21ca
commit
73f67fb132
|
@ -0,0 +1,4 @@
|
|||
export const value = 42;
|
||||
export * from "./imported.js";
|
||||
export { default as nested } from "./b.generate-json.js";
|
||||
export const random = Math.random();
|
|
@ -0,0 +1,2 @@
|
|||
export const value = 42;
|
||||
export * from "./imported.js";
|
|
@ -0,0 +1,2 @@
|
|||
export const a = "a";
|
||||
export const b = "b";
|
|
@ -0,0 +1,16 @@
|
|||
import a from "./a.generate-json.js";
|
||||
import { value as unrelated } from "./unrelated";
|
||||
|
||||
it("should have to correct values and validate on change", () => {
|
||||
const step = +WATCH_STEP;
|
||||
expect(a.value).toBe(42);
|
||||
expect(a.a).toBe("a");
|
||||
expect(a.nested.value).toBe(42);
|
||||
expect(a.nested.a).toBe("a");
|
||||
expect(a.b).toBe("b");
|
||||
expect(a.nested.b).toBe("b");
|
||||
if (step !== 0) {
|
||||
expect(STATE.random === a.random).toBe(step === 1);
|
||||
}
|
||||
STATE.random = a.random;
|
||||
});
|
|
@ -0,0 +1,7 @@
|
|||
/** @type {import("../../../../../").PitchLoaderDefinitionFunction} */
|
||||
exports.pitch = async function (remaining) {
|
||||
const result = await this.importModule(
|
||||
`${this.resourcePath}.webpack[javascript/auto]!=!${remaining}`
|
||||
);
|
||||
return JSON.stringify(result, null, 2);
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
export const value = 42;
|
|
@ -0,0 +1 @@
|
|||
export const value = 24;
|
|
@ -0,0 +1,43 @@
|
|||
const webpack = require("../../../../");
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
cache: {
|
||||
type: "filesystem"
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.generate-json\.js$/,
|
||||
use: "./loader",
|
||||
type: "json"
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProgressPlugin(),
|
||||
{
|
||||
apply(compiler) {
|
||||
compiler.hooks.done.tapPromise("CacheTest", async () => {
|
||||
const cache = compiler
|
||||
.getCache("ProgressPlugin")
|
||||
.getItemCache("counts", null);
|
||||
|
||||
const data = await cache.getPromise();
|
||||
|
||||
if (data.modulesCount !== 3) {
|
||||
throw new Error(
|
||||
`Wrong cached value of \`ProgressPlugin.modulesCount\` - ${data.modulesCount}, expect 3`
|
||||
);
|
||||
}
|
||||
|
||||
if (data.dependenciesCount !== 3) {
|
||||
throw new Error(
|
||||
`Wrong cached value of \`ProgressPlugin.dependenciesCount\` - ${data.dependenciesCount}, expect 3`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
Loading…
Reference in New Issue