Skip to content

Commit

Permalink
refactor: drop webpack v4 from tests, packages, and CI (#3338)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored and alexander-akait committed Nov 15, 2022
1 parent 1dabdd8 commit d86e06d
Show file tree
Hide file tree
Showing 29 changed files with 342 additions and 583 deletions.
5 changes: 4 additions & 1 deletion .cspell.json
Expand Up @@ -94,7 +94,10 @@
"Nitin",
"smoketest",
"dbaeumer",
"esbenp"
"esbenp",
"msuccessfully",
"mfirst",
"msecond"
],
"dictionaries": ["npm", "software-terms"],
"ignorePaths": [
Expand Down
2 changes: 1 addition & 1 deletion packages/configtest/package.json
Expand Up @@ -20,7 +20,7 @@
"lib"
],
"peerDependencies": {
"webpack": "4.x.x || 5.x.x",
"webpack": "5.x.x",
"webpack-cli": "4.x.x"
}
}
3 changes: 2 additions & 1 deletion packages/generators/package.json
Expand Up @@ -30,7 +30,8 @@
"yeoman-generator": "^4.12.0"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x"
"webpack": "5.x.x",
"webpack-cli": "4.x.x"
},
"peerDependenciesMeta": {
"prettier": {
Expand Down
1 change: 1 addition & 0 deletions packages/info/package.json
Expand Up @@ -24,6 +24,7 @@
},
"gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9",
"peerDependencies": {
"webpack": "5.x.x",
"webpack-cli": "4.x.x"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/serve/package.json
Expand Up @@ -21,6 +21,7 @@
"lib"
],
"peerDependencies": {
"webpack": "5.x.x",
"webpack-cli": "4.x.x"
},
"peerDependenciesMeta": {
Expand Down
1 change: 0 additions & 1 deletion packages/serve/src/index.ts
@@ -1,4 +1,3 @@
// eslint-disable-next-line node/no-extraneous-import
import type { Compiler, cli } from "webpack";
import { IWebpackCLI, WebpackDevServerOptions } from "webpack-cli";

Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cli/package.json
Expand Up @@ -48,7 +48,7 @@
"webpack-merge": "^5.7.3"
},
"peerDependencies": {
"webpack": "4.x.x || 5.x.x"
"webpack": "5.x.x"
},
"peerDependenciesMeta": {
"@webpack-cli/generators": {
Expand Down
146 changes: 55 additions & 91 deletions test/build/cache/cache.test.js
Expand Up @@ -3,7 +3,7 @@
const path = require("path");
// eslint-disable-next-line node/no-unpublished-require
const rimraf = require("rimraf");
const { run, isWebpack5 } = require("../../utils/test-utils");
const { run } = require("../../utils/test-utils");

describe("cache", () => {
it("should work", async () => {
Expand All @@ -14,25 +14,19 @@ describe("cache", () => {
let { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();

({ exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]));

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
});

it("should work in multi compiler mode", async () => {
Expand All @@ -46,25 +40,19 @@ describe("cache", () => {
let { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./multi.config.js"]);

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(2);
expect(stderr.match(/Stored pack/g)).toHaveLength(2);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/No pack exists at/g)).toHaveLength(2);
expect(stderr.match(/Stored pack/g)).toHaveLength(2);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();

({ exitCode, stderr, stdout } = await run(__dirname, ["-c", "./multi.config.js"]));

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/restore cache container:/g)).toHaveLength(2);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(2);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(2);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/restore cache container:/g)).toHaveLength(2);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(2);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(2);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
});

it("should work in multi compiler mode with the `--config-name` argument", async () => {
Expand All @@ -82,13 +70,10 @@ describe("cache", () => {
]);

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();

({ exitCode, stderr, stdout } = await run(__dirname, [
"-c",
Expand All @@ -100,14 +85,11 @@ describe("cache", () => {
]));

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
});

it("should work with the `--merge` argument", async () => {
Expand All @@ -126,13 +108,10 @@ describe("cache", () => {
]);

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();

({ exitCode, stderr, stdout } = await run(__dirname, [
"-c",
Expand All @@ -145,14 +124,11 @@ describe("cache", () => {
]));

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
});

it("should work with the `--config-name` and `--merge` argument", async () => {
Expand All @@ -175,13 +151,10 @@ describe("cache", () => {
]);

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();

({ exitCode, stderr, stdout } = await run(__dirname, [
"-c",
Expand All @@ -198,14 +171,11 @@ describe("cache", () => {
]));

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
});

it("should work with autoloading configuration", async () => {
Expand All @@ -219,24 +189,18 @@ describe("cache", () => {
let { exitCode, stderr, stdout } = await run(__dirname, ["--name", "cache-test-autoloading"]);

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/No pack exists at/g)).toHaveLength(1);
expect(stderr.match(/Stored pack/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();

({ exitCode, stderr, stdout } = await run(__dirname, ["--name", "cache-test-autoloading"]));

expect(exitCode).toEqual(0);

if (isWebpack5) {
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
expect(stderr.match(/restore cache container:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1);
expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
});
});

0 comments on commit d86e06d

Please sign in to comment.