diff --git a/package.json b/package.json index 7b5ebbd4cbd..d0d17c31e5d 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "@types/is-ci": "^3.0.4", "@types/jest": "29.5.14", "@types/node": "^20.12.7", - "@types/rimraf": "3.0.2", "check-dependency-version-consistency": "^5.0.0", "commander": "12.1.0", "cross-env": "^7.0.3", @@ -74,7 +73,7 @@ "lint-staged": "^15.0.0", "prettier": "3.4.2", "prettier-2": "npm:prettier@2.8.8", - "rimraf": "3.0.2", + "rimraf": "^5.0.10", "ts-jest": "29.2.5", "typescript": "^5.6.3", "webpack": "^5.94.0", diff --git a/packages/rspack-test-tools/package.json b/packages/rspack-test-tools/package.json index 903de01b6fa..4ed2dd7ada1 100644 --- a/packages/rspack-test-tools/package.json +++ b/packages/rspack-test-tools/package.json @@ -63,7 +63,7 @@ "mkdirp": "0.5.6", "path-serializer": "0.3.4", "pretty-format": "29.7.0", - "rimraf": "3.0.2", + "rimraf": "^5.0.10", "webpack": "^5.94.0", "webpack-merge": "5.9.0", "webpack-sources": "3.2.3" diff --git a/packages/rspack-test-tools/src/case/diff.ts b/packages/rspack-test-tools/src/case/diff.ts index 6cf7549770a..e127840e841 100644 --- a/packages/rspack-test-tools/src/case/diff.ts +++ b/packages/rspack-test-tools/src/case/diff.ts @@ -1,6 +1,6 @@ import path from "node:path"; import fs from "fs-extra"; -import rimraf from "rimraf"; +import { rimrafSync } from "rimraf"; import createLazyTestEnv from "../helper/legacy/createLazyTestEnv"; import { DiffProcessor, type IDiffProcessorOptions } from "../processor"; @@ -43,7 +43,7 @@ export function createDiffCase(name: string, src: string, dist: string) { }); beforeAll(async () => { - rimraf.sync(dist); + rimrafSync(dist); await tester.prepare(); }); diff --git a/packages/rspack-test-tools/src/helper/legacy/copyDiff.js b/packages/rspack-test-tools/src/helper/legacy/copyDiff.js index c26f87f2488..9fb4ee5026c 100644 --- a/packages/rspack-test-tools/src/helper/legacy/copyDiff.js +++ b/packages/rspack-test-tools/src/helper/legacy/copyDiff.js @@ -1,7 +1,7 @@ // @ts-nocheck const fs = require("node:fs"); const path = require("node:path"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); module.exports = function copyDiff(src, dest, initial) { fs.mkdirSync(dest, { recursive: true }); @@ -17,7 +17,7 @@ module.exports = function copyDiff(src, dest, initial) { if (/^DELETE\s*$/.test(content.toString("utf-8"))) { fs.unlinkSync(destFile); } else if (/^DELETE_DIRECTORY\s*$/.test(content.toString("utf-8"))) { - rimraf.sync(destFile); + rimrafSync(destFile); } else { fs.writeFileSync(destFile, content); if (initial) { diff --git a/packages/rspack-test-tools/src/test/creator.ts b/packages/rspack-test-tools/src/test/creator.ts index b87a4858ca5..68bf8ebd8ad 100644 --- a/packages/rspack-test-tools/src/test/creator.ts +++ b/packages/rspack-test-tools/src/test/creator.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; import path from "node:path"; -import rimraf from "rimraf"; +import { rimrafSync } from "rimraf"; import createLazyTestEnv from "../helper/legacy/createLazyTestEnv"; import type { @@ -125,7 +125,7 @@ export class BasicCaseCreator { protected clean(folders: string[]) { for (const f of folders) { - rimraf.sync(f); + rimrafSync(f); fs.mkdirSync(f, { recursive: true }); } } diff --git a/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js b/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js index a849a829225..c87ce9f41fc 100644 --- a/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js +++ b/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js @@ -1,6 +1,6 @@ const path = require("path"); const fs = require("fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); let first_asset_mtime; @@ -19,7 +19,7 @@ module.exports = { }; }, async build(context, compiler) { - rimraf.sync(context.getDist()); + rimrafSync(context.getDist()); await new Promise(resolve => { compiler.run(() => { first_asset_mtime = fs.statSync(path.join(context.getDist("main.js")))?.mtime; diff --git a/packages/rspack-test-tools/tests/compilerCases/compare-before-emit.js b/packages/rspack-test-tools/tests/compilerCases/compare-before-emit.js index 7bdd88baabe..22b64c64a84 100644 --- a/packages/rspack-test-tools/tests/compilerCases/compare-before-emit.js +++ b/packages/rspack-test-tools/tests/compilerCases/compare-before-emit.js @@ -1,6 +1,6 @@ const path = require("path"); const fs = require("fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); let first_asset_mtime; @@ -18,7 +18,7 @@ module.exports = { }; }, async build(context, compiler) { - rimraf.sync(context.getDist()); + rimrafSync(context.getDist()); await new Promise(resolve => { compiler.run(() => { first_asset_mtime = fs.statSync(path.join(context.getDist("main.js")))?.mtime; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1d1fbf3b8c..868592e3828 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,9 +43,6 @@ importers: '@types/node': specifier: ^20.12.7 version: 20.12.7 - '@types/rimraf': - specifier: 3.0.2 - version: 3.0.2 check-dependency-version-consistency: specifier: ^5.0.0 version: 5.0.0 @@ -80,8 +77,8 @@ importers: specifier: npm:prettier@2.8.8 version: prettier@2.8.8 rimraf: - specifier: 3.0.2 - version: 3.0.2 + specifier: ^5.0.10 + version: 5.0.10 ts-jest: specifier: 29.2.5 version: 29.2.5(@babel/core@7.24.4)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(jest@29.7.0(@types/node@20.12.7)(ts-node@10.9.2(@swc/core@1.10.1(@swc/helpers@0.5.15))(@types/node@20.12.7)(typescript@5.6.3)))(typescript@5.6.3) @@ -498,8 +495,8 @@ importers: specifier: 29.7.0 version: 29.7.0 rimraf: - specifier: 3.0.2 - version: 3.0.2 + specifier: ^5.0.10 + version: 5.0.10 webpack: specifier: ^5.94.0 version: 5.94.0(@swc/core@1.10.1(@swc/helpers@0.5.15))(webpack-cli@5.1.4(webpack@5.94.0)) @@ -928,9 +925,6 @@ importers: '@types/node': specifier: ^20.12.7 version: 20.12.7 - '@types/rimraf': - specifier: 3.0.2 - version: 3.0.2 '@types/watchpack': specifier: ^2.4.0 version: 2.4.4 @@ -1025,8 +1019,8 @@ importers: specifier: ^14.1.0 version: 14.1.0(react@18.3.1) rimraf: - specifier: 3.0.2 - version: 3.0.2 + specifier: ^5.0.10 + version: 5.0.10 sass-embedded: specifier: ^1.77.8 version: 1.81.0 @@ -3428,9 +3422,6 @@ packages: '@types/geojson@7946.0.15': resolution: {integrity: sha512-9oSxFzDCT2Rj6DfcHF8G++jxBKS7mBqXl5xrRW+Kbvjry6Uduya2iiwqHPhVXpasAVMBYKkEPGgKhd3+/HZ6xA==} - '@types/glob@8.1.0': - resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==} - '@types/graceful-fs@4.1.9': resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} @@ -3491,9 +3482,6 @@ packages: '@types/mime@1.3.5': resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==} - '@types/minimatch@5.1.2': - resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} - '@types/minimist@1.2.5': resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} @@ -3539,9 +3527,6 @@ packages: '@types/retry@0.12.2': resolution: {integrity: sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow==} - '@types/rimraf@3.0.2': - resolution: {integrity: sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ==} - '@types/semver@7.5.8': resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} @@ -8315,6 +8300,10 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true + rimraf@5.0.10: + resolution: {integrity: sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==} + hasBin: true + rimraf@5.0.9: resolution: {integrity: sha512-3i7b8OcswU6CpU8Ej89quJD4O98id7TtVM5U4Mybh84zQXdrFmDLouWBEEaD/QfO3gDDfH+AGFCGsR7kngzQnA==} engines: {node: 14 >=14.20 || 16 >=16.20 || >=18} @@ -12562,11 +12551,6 @@ snapshots: '@types/geojson@7946.0.15': {} - '@types/glob@8.1.0': - dependencies: - '@types/minimatch': 5.1.2 - '@types/node': 20.12.7 - '@types/graceful-fs@4.1.9': dependencies: '@types/node': 20.12.7 @@ -12638,8 +12622,6 @@ snapshots: '@types/mime@1.3.5': {} - '@types/minimatch@5.1.2': {} - '@types/minimist@1.2.5': {} '@types/ms@0.7.34': {} @@ -12683,11 +12665,6 @@ snapshots: '@types/retry@0.12.2': {} - '@types/rimraf@3.0.2': - dependencies: - '@types/glob': 8.1.0 - '@types/node': 20.12.7 - '@types/semver@7.5.8': {} '@types/send@0.17.4': @@ -18484,6 +18461,10 @@ snapshots: dependencies: glob: 7.2.3 + rimraf@5.0.10: + dependencies: + glob: 10.4.5 + rimraf@5.0.9: dependencies: glob: 10.4.5 diff --git a/tests/plugin-test/copy-plugin/CopyPlugin.test.js b/tests/plugin-test/copy-plugin/CopyPlugin.test.js index 6029cf14402..05dfc230370 100644 --- a/tests/plugin-test/copy-plugin/CopyPlugin.test.js +++ b/tests/plugin-test/copy-plugin/CopyPlugin.test.js @@ -6,13 +6,13 @@ const rspack = require("@rspack/core"); const { run, runEmit, runChange } = require("./helpers/run"); const { readAssets, getCompiler, compile } = require("./helpers"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const FIXTURES_DIR = path.join(__dirname, "fixtures"); describe("CopyPlugin", () => { beforeEach(() => { - rimraf.sync(path.join(__dirname, "build")); + rimrafSync(path.join(__dirname, "build")); }); describe("basic", () => { it("should copy a file", done => { diff --git a/tests/plugin-test/html-plugin/basic.test.js b/tests/plugin-test/html-plugin/basic.test.js index ba3d9d9e2b5..e2b524d5367 100644 --- a/tests/plugin-test/html-plugin/basic.test.js +++ b/tests/plugin-test/html-plugin/basic.test.js @@ -9,7 +9,7 @@ const path = require("path"); const fs = require("fs"); /// DIFF const webpack = require("webpack"); const webpack = require("@rspack/core"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const _ = require("lodash"); /// DIFF const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const MiniCssExtractPlugin = webpack.CssExtractRspackPlugin; @@ -119,8 +119,8 @@ function getChunksInfoFromStats(stats) { } describe("HtmlWebpackPlugin", () => { - beforeEach((done) => { - rimraf(OUTPUT_DIR, done); + beforeEach(() => { + rimrafSync(OUTPUT_DIR); }); it("generates a default index.html file for a single entry point", (done) => { diff --git a/tests/webpack-cli-test/build/cache/cache.test.js b/tests/webpack-cli-test/build/cache/cache.test.js index cd05719877c..1726733d26e 100644 --- a/tests/webpack-cli-test/build/cache/cache.test.js +++ b/tests/webpack-cli-test/build/cache/cache.test.js @@ -2,12 +2,12 @@ const path = require("path"); // eslint-disable-next-line node/no-unpublished-require -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const { run } = require("../../utils/test-utils"); describe("cache", () => { it("should work", async () => { - rimraf.sync( + rimrafSync( path.join(__dirname, "../../../node_modules/.cache/webpack/cache-test-default-development"), ); @@ -30,10 +30,10 @@ describe("cache", () => { }); it("should work in multi compiler mode", async () => { - rimraf.sync( + rimrafSync( path.join(__dirname, "../../../node_modules/.cache/webpack/cache-test-first-development"), ); - rimraf.sync( + rimrafSync( path.join(__dirname, "../../../node_modules/.cache/webpack/cache-test-second-development"), ); @@ -56,7 +56,7 @@ describe("cache", () => { }); it("should work in multi compiler mode with the `--config-name` argument", async () => { - rimraf.sync( + rimrafSync( path.join(__dirname, "../../../node_modules/.cache/webpack/cache-test-third-development"), ); @@ -93,7 +93,7 @@ describe("cache", () => { }); it("should work with the `--merge` argument", async () => { - rimraf.sync( + rimrafSync( path.join(__dirname, "../../../node_modules/.cache/webpack/cache-test-fourth-development"), ); @@ -132,7 +132,7 @@ describe("cache", () => { }); it("should work with the `--config-name` and `--merge` argument", async () => { - rimraf.sync( + rimrafSync( path.join(__dirname, "../../../node_modules/.cache/webpack/cache-test-fifth-development"), ); @@ -179,7 +179,7 @@ describe("cache", () => { }); it("should work with autoloading configuration", async () => { - rimraf.sync( + rimrafSync( path.join( __dirname, "../../../node_modules/.cache/webpack/cache-test-autoloading-development", diff --git a/tests/webpack-cli-test/scripts/cleanup-test.js b/tests/webpack-cli-test/scripts/cleanup-test.js index 0d495c55c12..4c7b3de0e0c 100644 --- a/tests/webpack-cli-test/scripts/cleanup-test.js +++ b/tests/webpack-cli-test/scripts/cleanup-test.js @@ -1,5 +1,5 @@ // eslint-disable-next-line node/no-unpublished-require -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const { join } = require("path"); const collectTestFolders = require("./utils"); @@ -22,7 +22,7 @@ const folderStrategy = (stats, file) => { const cleanupOutputDirs = () => { for (const outputFolder of collectTestFolders(folderStrategy)) { - outputDirectories.forEach((dir) => rimraf.sync(join(outputFolder, dir))); + outputDirectories.forEach((dir) => rimrafSync(join(outputFolder, dir))); } }; diff --git a/tests/webpack-test/BuildDependencies.longtest.js b/tests/webpack-test/BuildDependencies.longtest.js index bd18447d1f3..c80b3f9d106 100644 --- a/tests/webpack-test/BuildDependencies.longtest.js +++ b/tests/webpack-test/BuildDependencies.longtest.js @@ -3,7 +3,7 @@ const path = require("path"); const child_process = require("child_process"); const fs = require("fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const cacheDirectory = path.resolve(__dirname, "js/buildDepsCache"); const outputDirectory = path.resolve(__dirname, "js/buildDeps"); @@ -98,15 +98,15 @@ const exec = (n, options = {}) => { const supportsEsm = +process.versions.modules >= 83; describe.skip("BuildDependencies", () => { - beforeEach(done => { - rimraf(cacheDirectory, done); + beforeEach(() => { + rimrafSync(cacheDirectory); }); - beforeEach(done => { - rimraf(outputDirectory, done); + beforeEach(() => { + rimrafSync(outputDirectory); }); - beforeEach(done => { - rimraf(inputDirectory, done); + beforeEach(() => { + rimrafSync(inputDirectory); }); beforeEach(done => { fs.mkdir(inputDirectory, { recursive: true }, done); diff --git a/tests/webpack-test/ChangesAndRemovals.test.js b/tests/webpack-test/ChangesAndRemovals.test.js index f6eba236b7b..c938dcca69c 100644 --- a/tests/webpack-test/ChangesAndRemovals.test.js +++ b/tests/webpack-test/ChangesAndRemovals.test.js @@ -5,7 +5,7 @@ const path = require("path"); const { createFsFromVolume, Volume } = require("memfs"); const fs = require("graceful-fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const createCompiler = config => { const webpack = require("@rspack/core").rspack; @@ -47,7 +47,8 @@ const getChanges = compiler => { }; function cleanup(callback) { - rimraf(tempFolderPath, callback); + rimrafSync(tempFolderPath); + callback(); } function createFiles() { diff --git a/tests/webpack-test/Compiler-caching.test.js b/tests/webpack-test/Compiler-caching.test.js index ad58332a5c0..b60db760cf4 100644 --- a/tests/webpack-test/Compiler-caching.test.js +++ b/tests/webpack-test/Compiler-caching.test.js @@ -4,7 +4,7 @@ const path = require("path"); const fs = require("graceful-fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); let fixtureCount = 0; @@ -97,7 +97,7 @@ describe.skip("Compiler (caching)", () => { ); function cleanup() { - rimraf.sync(`${tempFixturePath}-*`); + rimrafSync(`${tempFixturePath}-*`); } beforeAll(cleanup); @@ -109,7 +109,7 @@ describe.skip("Compiler (caching)", () => { const cFilepath = path.join(fixturePath, "c.js"); // Remove previous copy if present - rimraf.sync(fixturePath); + rimrafSync(fixturePath); // Copy over file since we"ll be modifying some of them fs.mkdirSync(fixturePath); diff --git a/tests/webpack-test/ConfigTestCases.template.js b/tests/webpack-test/ConfigTestCases.template.js index 143696f8f8b..aac6a589163 100644 --- a/tests/webpack-test/ConfigTestCases.template.js +++ b/tests/webpack-test/ConfigTestCases.template.js @@ -6,7 +6,7 @@ const path = require("path"); const fs = require("graceful-fs"); const vm = require("vm"); const { URL, pathToFileURL, fileURLToPath } = require("url"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const checkArrayExpectation = require("./checkArrayExpectation"); const createLazyTestEnv = require("./helpers/createLazyTestEnv"); const deprecationTracking = require("./helpers/deprecationTracking"); @@ -174,7 +174,7 @@ const describeCases = config => { testConfig = undefined; }); beforeAll(() => { - rimraf.sync(cacheDirectory); + rimrafSync(cacheDirectory); }); const handleFatalError = (err, done) => { const fakeStats = { @@ -204,7 +204,7 @@ const describeCases = config => { it( `${testName} should pre-compile to fill disk cache (1st)`, done => { - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); fs.mkdirSync(outputDirectory, { recursive: true }); infraStructureLog.length = 0; const deprecationTracker = deprecationTracking.start(); @@ -248,7 +248,7 @@ const describeCases = config => { it( `${testName} should pre-compile to fill disk cache (2nd)`, done => { - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); fs.mkdirSync(outputDirectory, { recursive: true }); infraStructureLog.length = 0; const deprecationTracker = deprecationTracking.start(); @@ -321,7 +321,7 @@ const describeCases = config => { it( `${testName} should compile`, done => { - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); fs.mkdirSync(outputDirectory, { recursive: true }); infraStructureLog.length = 0; const deprecationTracker = deprecationTracking.start(); diff --git a/tests/webpack-test/HotTestCases.template.js b/tests/webpack-test/HotTestCases.template.js index 62021e19ea1..29bbf6ef51c 100644 --- a/tests/webpack-test/HotTestCases.template.js +++ b/tests/webpack-test/HotTestCases.template.js @@ -5,7 +5,7 @@ require("./helpers/warmup-webpack"); const path = require("path"); const fs = require("graceful-fs"); const vm = require("vm"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const checkArrayExpectation = require("./checkArrayExpectation"); const createLazyTestEnv = require("./helpers/createLazyTestEnv"); const { createFilteredDescribe } = require("./lib/util/filterUtil"); @@ -51,7 +51,7 @@ const describeCases = config => { category.name, testName ); - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); const recordsPath = path.join(outputDirectory, "records.json"); const fakeUpdateLoaderOptions = { updateIndex: 0 diff --git a/tests/webpack-test/MemoryLimitTestCases.test.js b/tests/webpack-test/MemoryLimitTestCases.test.js index a4270f8d9a5..e18fe71ca8a 100644 --- a/tests/webpack-test/MemoryLimitTestCases.test.js +++ b/tests/webpack-test/MemoryLimitTestCases.test.js @@ -3,7 +3,7 @@ // require("./helpers/warmup-webpack"); const path = require("path"); const fs = require("graceful-fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const captureStdio = require("./helpers/captureStdio"); const webpack = require("@rspack/core").rspack; const { createFilteredDescribe } = require("./lib/util/filterUtil") @@ -54,7 +54,7 @@ describe("MemoryLimitTestCases", () => { testConfig.heapSizeLimitBytes )}`, done => { const outputDirectory = path.join(outputBase, testName); - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); fs.mkdirSync(outputDirectory, { recursive: true }); let options = { mode: "development", diff --git a/tests/webpack-test/PersistentCaching.test.js b/tests/webpack-test/PersistentCaching.test.js index a8fbc8635ac..4301de2b8d9 100644 --- a/tests/webpack-test/PersistentCaching.test.js +++ b/tests/webpack-test/PersistentCaching.test.js @@ -3,7 +3,7 @@ const path = require("path"); const util = require("util"); const fs = require("fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const vm = require("vm"); const readdir = util.promisify(fs.readdir); @@ -37,8 +37,8 @@ describe.skip("Persistent Caching", () => { } }; - beforeEach(done => { - rimraf(tempPath, done); + beforeEach(() => { + rimrafSync(tempPath); }); const updateSrc = async data => { diff --git a/tests/webpack-test/ProfilingPlugin.test.js b/tests/webpack-test/ProfilingPlugin.test.js index 5fa103e86de..138d0085484 100644 --- a/tests/webpack-test/ProfilingPlugin.test.js +++ b/tests/webpack-test/ProfilingPlugin.test.js @@ -4,7 +4,7 @@ const path = require("path"); const fs = require("graceful-fs"); -const rimraf = require("rimraf"); +const { rimraf } = require("rimraf"); describe.skip("Profiling Plugin", function () { jest.setTimeout(120000); @@ -14,7 +14,8 @@ describe.skip("Profiling Plugin", function () { const outputPath = path.join(__dirname, "js/profilingPath"); const finalPath = path.join(outputPath, "events.json"); let counter = 0; - rimraf(outputPath, () => { + + rimraf(outputPath).then(() => { const startTime = process.hrtime(); const compiler = webpack({ context: __dirname, diff --git a/tests/webpack-test/StatsTestCases.basictest.js b/tests/webpack-test/StatsTestCases.basictest.js index ccfa106411e..cdf37c86bbf 100644 --- a/tests/webpack-test/StatsTestCases.basictest.js +++ b/tests/webpack-test/StatsTestCases.basictest.js @@ -3,7 +3,7 @@ require("./helpers/warmup-webpack"); const path = require("path"); const fs = require("graceful-fs"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const captureStdio = require("./helpers/captureStdio"); const webpack = require("@rspack/core"); const { createFilteredDescribe } = require('./lib/util/filterUtil') @@ -50,7 +50,7 @@ describe("StatsTestCases", () => { tests.forEach(testName => { it("should print correct stats for " + testName, done => { const outputDirectory = path.join(outputBase, testName); - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); fs.mkdirSync(outputDirectory, { recursive: true }); let options = { mode: "development", diff --git a/tests/webpack-test/TestCases.template.js b/tests/webpack-test/TestCases.template.js index fe5c8ea0758..8421e668616 100644 --- a/tests/webpack-test/TestCases.template.js +++ b/tests/webpack-test/TestCases.template.js @@ -5,7 +5,7 @@ const path = require("path"); const fs = require("graceful-fs"); const vm = require("vm"); const { pathToFileURL, URL } = require("url"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const checkArrayExpectation = require("./checkArrayExpectation"); const createLazyTestEnv = require("./helpers/createLazyTestEnv"); const deprecationTracking = require("./helpers/deprecationTracking"); @@ -232,8 +232,8 @@ const describeCases = config => { testConfig = undefined; for (const fn of cleanups) fn(); }); - beforeAll(done => { - rimraf(cacheDirectory, done); + beforeAll(() => { + rimrafSync(cacheDirectory); }); if (config.cache) { it( diff --git a/tests/webpack-test/WatchTestCases.template.js b/tests/webpack-test/WatchTestCases.template.js index 4cac491fd28..cd9c5e155a0 100644 --- a/tests/webpack-test/WatchTestCases.template.js +++ b/tests/webpack-test/WatchTestCases.template.js @@ -5,7 +5,7 @@ require("./helpers/warmup-webpack"); const path = require("path"); const fs = require("graceful-fs"); const vm = require("vm"); -const rimraf = require("rimraf"); +const { rimrafSync } = require("rimraf"); const checkArrayExpectation = require("./checkArrayExpectation"); const createLazyTestEnv = require("./helpers/createLazyTestEnv"); const { remove } = require("./helpers/remove"); @@ -28,7 +28,7 @@ function copyDiff(src, dest, initial) { if (/^DELETE\s*$/.test(content.toString("utf-8"))) { fs.unlinkSync(destFile); } else if (/^DELETE_DIRECTORY\s*$/.test(content.toString("utf-8"))) { - rimraf.sync(destFile); + rimrafSync(destFile); } else { fs.writeFileSync(destFile, content); if (initial) { @@ -105,8 +105,8 @@ const describeCases = config => { }) .map(name => ({ name })); - beforeAll(done => { - rimraf(tempDirectory, done); + beforeAll(() => { + rimrafSync(tempDirectory); }); it( @@ -120,7 +120,7 @@ const describeCases = config => { testName ); - rimraf.sync(outputDirectory); + rimrafSync(outputDirectory); let options = {}; const configPath = path.join( diff --git a/tests/webpack-test/package.json b/tests/webpack-test/package.json index 73cb14f291a..9fccee02d3f 100644 --- a/tests/webpack-test/package.json +++ b/tests/webpack-test/package.json @@ -19,7 +19,6 @@ "@rspack/core": "workspace:*", "node-polyfill-webpack-plugin": "3.0.0", "@types/node": "^20.12.7", - "@types/rimraf": "3.0.2", "@types/watchpack": "^2.4.0", "@types/webpack-sources": "3.2.3", "@types/ws": "8.5.10", @@ -48,7 +47,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-relay": "^14.1.0", - "rimraf": "3.0.2", + "rimraf": "^5.0.10", "mini-svg-data-uri": "^1.2.3", "mime-types": "^2.1.27", "url-loader": "^4.1.0",