From b881003d0b0cb195851993e4b955e7ae9f62dce5 Mon Sep 17 00:00:00 2001 From: Hana Date: Thu, 28 Dec 2023 18:21:45 +0800 Subject: [PATCH 1/8] add test case --- .../context-delete-file}/index.test.ts | 0 .../context-delete-file}/rspack.config.js | 0 .../context-delete-file}/src/index.html | 0 .../context-delete-file}/src/index.js | 0 .../context-delete-file}/src/mod1.js | 0 .../context-delete-file}/src/mod2.js | 0 .../cases/file/missing-files/index.test.ts | 24 ++++++++++++++++++ .../cases/file/missing-files/rspack.config.js | 25 +++++++++++++++++++ .../cases/file/missing-files/src/index.html | 15 +++++++++++ .../cases/file/missing-files/src/index.js | 6 +++++ 10 files changed, 70 insertions(+) rename packages/playground/cases/{context/delete-file => file/context-delete-file}/index.test.ts (100%) rename packages/playground/cases/{context/delete-file => file/context-delete-file}/rspack.config.js (100%) rename packages/playground/cases/{context/delete-file => file/context-delete-file}/src/index.html (100%) rename packages/playground/cases/{context/delete-file => file/context-delete-file}/src/index.js (100%) rename packages/playground/cases/{context/delete-file => file/context-delete-file}/src/mod1.js (100%) rename packages/playground/cases/{context/delete-file => file/context-delete-file}/src/mod2.js (100%) create mode 100644 packages/playground/cases/file/missing-files/index.test.ts create mode 100644 packages/playground/cases/file/missing-files/rspack.config.js create mode 100644 packages/playground/cases/file/missing-files/src/index.html create mode 100644 packages/playground/cases/file/missing-files/src/index.js diff --git a/packages/playground/cases/context/delete-file/index.test.ts b/packages/playground/cases/file/context-delete-file/index.test.ts similarity index 100% rename from packages/playground/cases/context/delete-file/index.test.ts rename to packages/playground/cases/file/context-delete-file/index.test.ts diff --git a/packages/playground/cases/context/delete-file/rspack.config.js b/packages/playground/cases/file/context-delete-file/rspack.config.js similarity index 100% rename from packages/playground/cases/context/delete-file/rspack.config.js rename to packages/playground/cases/file/context-delete-file/rspack.config.js diff --git a/packages/playground/cases/context/delete-file/src/index.html b/packages/playground/cases/file/context-delete-file/src/index.html similarity index 100% rename from packages/playground/cases/context/delete-file/src/index.html rename to packages/playground/cases/file/context-delete-file/src/index.html diff --git a/packages/playground/cases/context/delete-file/src/index.js b/packages/playground/cases/file/context-delete-file/src/index.js similarity index 100% rename from packages/playground/cases/context/delete-file/src/index.js rename to packages/playground/cases/file/context-delete-file/src/index.js diff --git a/packages/playground/cases/context/delete-file/src/mod1.js b/packages/playground/cases/file/context-delete-file/src/mod1.js similarity index 100% rename from packages/playground/cases/context/delete-file/src/mod1.js rename to packages/playground/cases/file/context-delete-file/src/mod1.js diff --git a/packages/playground/cases/context/delete-file/src/mod2.js b/packages/playground/cases/file/context-delete-file/src/mod2.js similarity index 100% rename from packages/playground/cases/context/delete-file/src/mod2.js rename to packages/playground/cases/file/context-delete-file/src/mod2.js diff --git a/packages/playground/cases/file/missing-files/index.test.ts b/packages/playground/cases/file/missing-files/index.test.ts new file mode 100644 index 00000000000..d7ad1db3473 --- /dev/null +++ b/packages/playground/cases/file/missing-files/index.test.ts @@ -0,0 +1,24 @@ +import { test, expect } from "@/fixtures"; + +test("missing files", async ({ page, fileAction }) => { + let overlay = page.frameLocator("#webpack-dev-server-client-overlay"); + await expect( + overlay.getByText("Failed to resolve ./missing-file-1") + ).toBeVisible(); + await expect( + overlay.getByText("Failed to resolve ./missing-file-2") + ).toBeVisible(); + + fileAction.updateFile( + "src/missing-file-1.js", + () => "export const a = 'missing-file-1'" + ); + + fileAction.updateFile( + "src/missing-file-2.js", + () => "export const b = 'missing-file-2'" + ); + + await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1"); + await expect(page.locator("#missing-file-2")).toHaveText("missing-file-2"); +}); diff --git a/packages/playground/cases/file/missing-files/rspack.config.js b/packages/playground/cases/file/missing-files/rspack.config.js new file mode 100644 index 00000000000..077dc43a0c1 --- /dev/null +++ b/packages/playground/cases/file/missing-files/rspack.config.js @@ -0,0 +1,25 @@ +module.exports = { + context: __dirname, + mode: "development", + entry: { + main: "./src/index.js" + }, + devServer: { + hot: true + }, + cache: false, + stats: "none", + infrastructureLogging: { + debug: false + }, + builtins: { + html: [ + { + template: "./src/index.html" + } + ] + }, + watchOptions: { + poll: 1000 + } +}; diff --git a/packages/playground/cases/file/missing-files/src/index.html b/packages/playground/cases/file/missing-files/src/index.html new file mode 100644 index 00000000000..98b4c272882 --- /dev/null +++ b/packages/playground/cases/file/missing-files/src/index.html @@ -0,0 +1,15 @@ + + + + + + + + Document + + + +
+ + + \ No newline at end of file diff --git a/packages/playground/cases/file/missing-files/src/index.js b/packages/playground/cases/file/missing-files/src/index.js new file mode 100644 index 00000000000..5ef78bfade4 --- /dev/null +++ b/packages/playground/cases/file/missing-files/src/index.js @@ -0,0 +1,6 @@ +import { a } from "./missing-file-1"; +const { b } = require("./missing-file-2"); + +document.getElementById( + "root" +).innerHTML = `${a}${b}`; From 1958306b432e42a72df1802866afcf6b35959810 Mon Sep 17 00:00:00 2001 From: Hana Date: Thu, 4 Jan 2024 11:58:32 +0800 Subject: [PATCH 2/8] adapt new oxc resolver --- crates/rspack_core/src/resolver/mod.rs | 18 +++--- .../rspack_core/src/resolver/resolver_impl.rs | 63 ++++++++++++++++--- 2 files changed, 67 insertions(+), 14 deletions(-) diff --git a/crates/rspack_core/src/resolver/mod.rs b/crates/rspack_core/src/resolver/mod.rs index d8bcde6e7fc..eb8eca8a2c4 100644 --- a/crates/rspack_core/src/resolver/mod.rs +++ b/crates/rspack_core/src/resolver/mod.rs @@ -57,11 +57,9 @@ impl Resource { /// Main entry point for module resolution. pub async fn resolve( - args: ResolveArgs<'_>, + mut args: ResolveArgs<'_>, plugin_driver: &SharedPluginDriver, ) -> Result { - let mut args = args; - let dep = ResolveOptionsWithDependencyType { resolve_options: args.resolve_options.take(), resolve_to_context: args.resolve_to_context, @@ -71,14 +69,20 @@ pub async fn resolve( let base_dir = args.context.clone(); let base_dir = base_dir.as_ref(); + let mut context = Default::default(); let resolver = plugin_driver.resolver_factory.get(dep); let result = resolver - .resolve(base_dir, args.specifier) + .resolve_with_context(base_dir, args.specifier, &mut context) .map_err(|error| error.into_resolve_error(&args)); - let (file_dependencies, missing_dependencies) = resolver.dependencies(); - args.file_dependencies.extend(file_dependencies); - args.missing_dependencies.extend(missing_dependencies); + let ResolveArgs { + file_dependencies, + missing_dependencies, + .. + } = args; + + file_dependencies.extend(context.file_dependencies); + missing_dependencies.extend(context.missing_dependencies); result } diff --git a/crates/rspack_core/src/resolver/resolver_impl.rs b/crates/rspack_core/src/resolver/resolver_impl.rs index f7268b7de76..a0c8bc01734 100644 --- a/crates/rspack_core/src/resolver/resolver_impl.rs +++ b/crates/rspack_core/src/resolver/resolver_impl.rs @@ -8,10 +8,19 @@ use rspack_error::{ error, miette::miette, DiagnosticError, Error, ErrorExt, Severity, TraceableError, }; use rspack_loader_runner::DescriptionData; +use rustc_hash::FxHashSet as HashSet; use super::{ResolveResult, Resource}; use crate::{DependencyCategory, Resolve, ResolveArgs, ResolveOptionsWithDependencyType}; +#[derive(Debug, Default, Clone)] +pub struct ResolveContext { + /// Files that was found on file system + pub file_dependencies: HashSet, + /// Dependencies that was not found on file system + pub missing_dependencies: HashSet, +} + /// Proxy to [nodejs_resolver::Error] or [oxc_resolver::ResolveError] #[derive(Debug)] pub enum ResolveInnerError { @@ -145,13 +154,6 @@ impl Resolver { } } - /// Return `dependencies` from `enhanced-resolve` - /// - /// Implementation is currently blank. - pub fn dependencies(&self) -> (Vec, Vec) { - (vec![], vec![]) - } - /// Return the options from the resolver pub fn options(&self) -> ResolveInnerOptions<'_> { match self { @@ -191,6 +193,53 @@ impl Resolver { }, } } + + /// Resolve a specifier to a given path. + pub fn resolve_with_context( + &self, + path: &Path, + request: &str, + resolve_context: &mut ResolveContext, + ) -> Result { + match self { + Self::NodejsResolver(resolver, _) => resolver + .resolve(path, request) + .map(|result| match result { + nodejs_resolver::ResolveResult::Resource(r) => ResolveResult::Resource(Resource { + path: r.path, + query: r.query, + fragment: r.fragment, + description_data: r.description.map(|d| { + DescriptionData::new(d.dir().as_ref().to_path_buf(), Arc::clone(d.data().raw())) + }), + }), + nodejs_resolver::ResolveResult::Ignored => ResolveResult::Ignored, + }) + .map_err(ResolveInnerError::NodejsResolver), + Self::OxcResolver(resolver) => { + let mut context = Default::default(); + let result = resolver.resolve_with_context(path, request, &mut context); + + // resolve_context + // .file_dependencies + // .extend(context.file_dependencies); + // resolve_context.missing_dependencies.extend(); + + match result { + Ok(r) => Ok(ResolveResult::Resource(Resource { + path: r.path().to_path_buf(), + query: r.query().map(ToString::to_string), + fragment: r.fragment().map(ToString::to_string), + description_data: r + .package_json() + .map(|d| DescriptionData::new(d.directory().to_path_buf(), Arc::clone(&d.raw_json))), + })), + Err(oxc_resolver::ResolveError::Ignored(_)) => Ok(ResolveResult::Ignored), + Err(error) => Err(ResolveInnerError::OxcResolver(error)), + } + } + } + } } impl ResolveInnerError { From 308fc14c3ad2c5fe6f1fc89285f7021db5654b6f Mon Sep 17 00:00:00 2001 From: Hana Date: Thu, 4 Jan 2024 18:21:06 +0800 Subject: [PATCH 3/8] fix --- crates/rspack_core/src/resolver/mod.rs | 12 ++++------ .../rspack_core/src/resolver/resolver_impl.rs | 23 +++++++++++++------ .../cases/file/missing-files/index.test.ts | 12 ++++++---- packages/rspack/src/Watching.ts | 4 ++++ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/crates/rspack_core/src/resolver/mod.rs b/crates/rspack_core/src/resolver/mod.rs index eb8eca8a2c4..3609ceb3864 100644 --- a/crates/rspack_core/src/resolver/mod.rs +++ b/crates/rspack_core/src/resolver/mod.rs @@ -75,14 +75,10 @@ pub async fn resolve( .resolve_with_context(base_dir, args.specifier, &mut context) .map_err(|error| error.into_resolve_error(&args)); - let ResolveArgs { - file_dependencies, - missing_dependencies, - .. - } = args; - - file_dependencies.extend(context.file_dependencies); - missing_dependencies.extend(context.missing_dependencies); + args.file_dependencies.extend(context.file_dependencies); + args + .missing_dependencies + .extend(context.missing_dependencies); result } diff --git a/crates/rspack_core/src/resolver/resolver_impl.rs b/crates/rspack_core/src/resolver/resolver_impl.rs index a0c8bc01734..14b8e3d03cf 100644 --- a/crates/rspack_core/src/resolver/resolver_impl.rs +++ b/crates/rspack_core/src/resolver/resolver_impl.rs @@ -219,12 +219,21 @@ impl Resolver { Self::OxcResolver(resolver) => { let mut context = Default::default(); let result = resolver.resolve_with_context(path, request, &mut context); - - // resolve_context - // .file_dependencies - // .extend(context.file_dependencies); - // resolve_context.missing_dependencies.extend(); - + println!( + "file: {:?}\nmissing:{:?}\nintersection:{:?}", + &context.file_dependencies, + &context.missing_dependencies, + context + .file_dependencies + .intersection(&context.missing_dependencies) + .collect::>() + ); + resolve_context + .file_dependencies + .extend(context.file_dependencies); + resolve_context + .missing_dependencies + .extend(context.missing_dependencies); match result { Ok(r) => Ok(ResolveResult::Resource(Resource { path: r.path().to_path_buf(), @@ -232,7 +241,7 @@ impl Resolver { fragment: r.fragment().map(ToString::to_string), description_data: r .package_json() - .map(|d| DescriptionData::new(d.directory().to_path_buf(), Arc::clone(&d.raw_json))), + .map(|d| DescriptionData::new(d.directory().to_path_buf(), Arc::clone(d.raw_json()))), })), Err(oxc_resolver::ResolveError::Ignored(_)) => Ok(ResolveResult::Ignored), Err(error) => Err(ResolveInnerError::OxcResolver(error)), diff --git a/packages/playground/cases/file/missing-files/index.test.ts b/packages/playground/cases/file/missing-files/index.test.ts index d7ad1db3473..ea7ca246c7d 100644 --- a/packages/playground/cases/file/missing-files/index.test.ts +++ b/packages/playground/cases/file/missing-files/index.test.ts @@ -3,10 +3,10 @@ import { test, expect } from "@/fixtures"; test("missing files", async ({ page, fileAction }) => { let overlay = page.frameLocator("#webpack-dev-server-client-overlay"); await expect( - overlay.getByText("Failed to resolve ./missing-file-1") + overlay.getByText("Can't resolve './missing-file-1'") ).toBeVisible(); await expect( - overlay.getByText("Failed to resolve ./missing-file-2") + overlay.getByText("Can't resolve './missing-file-2'") ).toBeVisible(); fileAction.updateFile( @@ -19,6 +19,10 @@ test("missing files", async ({ page, fileAction }) => { () => "export const b = 'missing-file-2'" ); - await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1"); - await expect(page.locator("#missing-file-2")).toHaveText("missing-file-2"); + await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1", { + timeout: 30 * 1000 + }); + await expect(page.locator("#missing-file-2")).toHaveText("missing-file-2", { + timeout: 30 * 1000 + }); }); diff --git a/packages/rspack/src/Watching.ts b/packages/rspack/src/Watching.ts index 16fcb6768cd..60ccf66de86 100644 --- a/packages/rspack/src/Watching.ts +++ b/packages/rspack/src/Watching.ts @@ -329,6 +329,10 @@ export class Watching { if (err) return handleError(err, cbs); // @ts-expect-error this.handler(null, stats); + console.log( + [...compilation.fileDependencies], + [...compilation.missingDependencies] + ); process.nextTick(() => { if (!this.#closed) { From f16dff7278fcf4740a04fdd2dbd68234db9fc1e9 Mon Sep 17 00:00:00 2001 From: Hana Date: Fri, 5 Jan 2024 15:53:57 +0800 Subject: [PATCH 4/8] fix --- crates/rspack_core/src/compiler/queue.rs | 4 ++-- crates/rspack_core/src/normal_module_factory.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/rspack_core/src/compiler/queue.rs b/crates/rspack_core/src/compiler/queue.rs index 321745dfe02..e658eb4b01b 100644 --- a/crates/rspack_core/src/compiler/queue.rs +++ b/crates/rspack_core/src/compiler/queue.rs @@ -163,7 +163,7 @@ impl WorkerTask for FactorizeTask { .with_diagnostics(diagnostics) .with_file_dependencies(create_data.file_dependencies.drain()) .with_missing_dependencies(create_data.missing_dependencies.drain()) - .with_context_dependencies(create_data.missing_dependencies.drain()), + .with_context_dependencies(create_data.context_dependencies.drain()), ))) } Err(mut e) => { @@ -188,7 +188,7 @@ impl WorkerTask for FactorizeTask { .with_diagnostics(diagnostics) .with_file_dependencies(create_data.file_dependencies.drain()) .with_missing_dependencies(create_data.missing_dependencies.drain()) - .with_context_dependencies(create_data.missing_dependencies.drain()), + .with_context_dependencies(create_data.context_dependencies.drain()), ))) } } diff --git a/crates/rspack_core/src/normal_module_factory.rs b/crates/rspack_core/src/normal_module_factory.rs index 050c2cd7612..d22f001b6d8 100644 --- a/crates/rspack_core/src/normal_module_factory.rs +++ b/crates/rspack_core/src/normal_module_factory.rs @@ -306,6 +306,7 @@ impl NormalModuleFactory { Ok(result) => result, Err(err) => (Err(err), false), }; + match resource_data { Ok(ResolveResult::Resource(resource)) => { let uri = resource.full_path().display().to_string(); @@ -334,6 +335,8 @@ impl NormalModuleFactory { )); } Err(err) => { + data.add_file_dependencies(file_dependencies); + data.add_missing_dependencies(missing_dependencies); // let mut file_dependencies = Default::default(); // let mut missing_dependencies = Default::default(); // let mut from_cache_result = from_cache; From 067e4e3745ad6dd6ccec31373c0630cc2622168f Mon Sep 17 00:00:00 2001 From: Hana Date: Fri, 5 Jan 2024 15:55:40 +0800 Subject: [PATCH 5/8] clean up --- crates/rspack_core/src/resolver/resolver_impl.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/rspack_core/src/resolver/resolver_impl.rs b/crates/rspack_core/src/resolver/resolver_impl.rs index 14b8e3d03cf..318ebcd8b4e 100644 --- a/crates/rspack_core/src/resolver/resolver_impl.rs +++ b/crates/rspack_core/src/resolver/resolver_impl.rs @@ -219,15 +219,6 @@ impl Resolver { Self::OxcResolver(resolver) => { let mut context = Default::default(); let result = resolver.resolve_with_context(path, request, &mut context); - println!( - "file: {:?}\nmissing:{:?}\nintersection:{:?}", - &context.file_dependencies, - &context.missing_dependencies, - context - .file_dependencies - .intersection(&context.missing_dependencies) - .collect::>() - ); resolve_context .file_dependencies .extend(context.file_dependencies); From 366a347d39810fed72840c336ac0151bda58c3cf Mon Sep 17 00:00:00 2001 From: Hana Date: Fri, 5 Jan 2024 16:05:26 +0800 Subject: [PATCH 6/8] clean up --- .../cases/file/missing-files/index.test.ts | 20 ++++++++++++++++++- .../cases/file/missing-files/src/index.js | 8 +++++--- packages/rspack/src/Watching.ts | 4 ---- packages/rspack/tests/StatsTestCases.test.ts | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/playground/cases/file/missing-files/index.test.ts b/packages/playground/cases/file/missing-files/index.test.ts index ea7ca246c7d..9e95b590337 100644 --- a/packages/playground/cases/file/missing-files/index.test.ts +++ b/packages/playground/cases/file/missing-files/index.test.ts @@ -1,6 +1,9 @@ import { test, expect } from "@/fixtures"; -test("missing files", async ({ page, fileAction }) => { +test("missing files should be able to recover if being added back", async ({ + page, + fileAction +}) => { let overlay = page.frameLocator("#webpack-dev-server-client-overlay"); await expect( overlay.getByText("Can't resolve './missing-file-1'") @@ -25,4 +28,19 @@ test("missing files", async ({ page, fileAction }) => { await expect(page.locator("#missing-file-2")).toHaveText("missing-file-2", { timeout: 30 * 1000 }); + + fileAction.deleteFile("src/missing-file-1.js"); + + await expect( + overlay.getByText("Can't resolve './missing-file-1'") + ).toBeVisible(); + + fileAction.updateFile( + "src/missing-file-1.js", + () => "export const a = 'missing-file-1'" + ); + + await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1", { + timeout: 30 * 1000 + }); }); diff --git a/packages/playground/cases/file/missing-files/src/index.js b/packages/playground/cases/file/missing-files/src/index.js index 5ef78bfade4..006a6dfe50f 100644 --- a/packages/playground/cases/file/missing-files/src/index.js +++ b/packages/playground/cases/file/missing-files/src/index.js @@ -1,6 +1,8 @@ +// @ts-nocheck import { a } from "./missing-file-1"; const { b } = require("./missing-file-2"); -document.getElementById( - "root" -).innerHTML = `${a}${b}`; +document.getElementById("root").innerHTML = ` +${a} +${b} +`; diff --git a/packages/rspack/src/Watching.ts b/packages/rspack/src/Watching.ts index 60ccf66de86..16fcb6768cd 100644 --- a/packages/rspack/src/Watching.ts +++ b/packages/rspack/src/Watching.ts @@ -329,10 +329,6 @@ export class Watching { if (err) return handleError(err, cbs); // @ts-expect-error this.handler(null, stats); - console.log( - [...compilation.fileDependencies], - [...compilation.missingDependencies] - ); process.nextTick(() => { if (!this.#closed) { diff --git a/packages/rspack/tests/StatsTestCases.test.ts b/packages/rspack/tests/StatsTestCases.test.ts index 2adf3ce6025..8f82cb1d235 100644 --- a/packages/rspack/tests/StatsTestCases.test.ts +++ b/packages/rspack/tests/StatsTestCases.test.ts @@ -96,7 +96,7 @@ describe("StatsTestCases", () => { expect(statsJson).toMatchSnapshot(); let statsString = stats.toString(statsOptions); - expect(statsString.replace(/\n[ ]+│ /, "")).toMatchSnapshot(); + expect(replace(statsString)).toMatchSnapshot(); }); }); }); From 78f7d30fd38b7d27841e0fc16d7b34c183d763cf Mon Sep 17 00:00:00 2001 From: Hana Date: Thu, 4 Jan 2024 18:21:06 +0800 Subject: [PATCH 7/8] fix --- packages/rspack/src/Watching.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/rspack/src/Watching.ts b/packages/rspack/src/Watching.ts index 16fcb6768cd..60ccf66de86 100644 --- a/packages/rspack/src/Watching.ts +++ b/packages/rspack/src/Watching.ts @@ -329,6 +329,10 @@ export class Watching { if (err) return handleError(err, cbs); // @ts-expect-error this.handler(null, stats); + console.log( + [...compilation.fileDependencies], + [...compilation.missingDependencies] + ); process.nextTick(() => { if (!this.#closed) { From c7c598e341331bc79300aed7e0b79a81b6209975 Mon Sep 17 00:00:00 2001 From: Hana Date: Fri, 5 Jan 2024 16:05:26 +0800 Subject: [PATCH 8/8] clean up --- .../cases/file/missing-files/index.test.ts | 12 +++--------- packages/rspack/src/Watching.ts | 4 ---- packages/rspack/tests/MultiCompiler.test.ts | 11 ++++++++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/playground/cases/file/missing-files/index.test.ts b/packages/playground/cases/file/missing-files/index.test.ts index 9e95b590337..e777434832e 100644 --- a/packages/playground/cases/file/missing-files/index.test.ts +++ b/packages/playground/cases/file/missing-files/index.test.ts @@ -22,12 +22,8 @@ test("missing files should be able to recover if being added back", async ({ () => "export const b = 'missing-file-2'" ); - await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1", { - timeout: 30 * 1000 - }); - await expect(page.locator("#missing-file-2")).toHaveText("missing-file-2", { - timeout: 30 * 1000 - }); + await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1"); + await expect(page.locator("#missing-file-2")).toHaveText("missing-file-2"); fileAction.deleteFile("src/missing-file-1.js"); @@ -40,7 +36,5 @@ test("missing files should be able to recover if being added back", async ({ () => "export const a = 'missing-file-1'" ); - await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1", { - timeout: 30 * 1000 - }); + await expect(page.locator("#missing-file-1")).toHaveText("missing-file-1"); }); diff --git a/packages/rspack/src/Watching.ts b/packages/rspack/src/Watching.ts index 60ccf66de86..16fcb6768cd 100644 --- a/packages/rspack/src/Watching.ts +++ b/packages/rspack/src/Watching.ts @@ -329,10 +329,6 @@ export class Watching { if (err) return handleError(err, cbs); // @ts-expect-error this.handler(null, stats); - console.log( - [...compilation.fileDependencies], - [...compilation.missingDependencies] - ); process.nextTick(() => { if (!this.#closed) { diff --git a/packages/rspack/tests/MultiCompiler.test.ts b/packages/rspack/tests/MultiCompiler.test.ts index 753dfb8faca..0f1184ec913 100644 --- a/packages/rspack/tests/MultiCompiler.test.ts +++ b/packages/rspack/tests/MultiCompiler.test.ts @@ -488,10 +488,15 @@ describe("MultiCompiler", function () { compiler.watch({}, err => { if (err) { - done(err); - } else { - done(); + compiler.close(() => { + done(err); + }); + return; } + compiler.close(err => { + if (err) return done(err); + done(); + }); }); }, 20000);