From 7eaffce69d92de6f8e9dc56783f0aedede36e8e5 Mon Sep 17 00:00:00 2001 From: "zhanghang.heal" Date: Wed, 27 Nov 2024 15:19:10 +0800 Subject: [PATCH 1/2] fix: watchOptions.ignored use array glob instead of regexp --- .changeset/sharp-bikes-shout.md | 5 +++++ packages/core/src/plugins/basic.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/sharp-bikes-shout.md diff --git a/.changeset/sharp-bikes-shout.md b/.changeset/sharp-bikes-shout.md new file mode 100644 index 0000000000..b9f1519c07 --- /dev/null +++ b/.changeset/sharp-bikes-shout.md @@ -0,0 +1,5 @@ +--- +'@rsbuild/core': patch +--- + +fix: watchOptions.ignored use array glob instead of regexp diff --git a/packages/core/src/plugins/basic.ts b/packages/core/src/plugins/basic.ts index 6b7fbe9ae9..efd49b7a29 100644 --- a/packages/core/src/plugins/basic.ts +++ b/packages/core/src/plugins/basic.ts @@ -52,7 +52,7 @@ export const pluginBasic = (): RsbuildPlugin => ({ chain.watchOptions({ // Ignore watching files in node_modules to reduce memory usage and make startup faster - ignored: /[\\/](?:\.git|node_modules)[\\/]/, + ignored: ['**/.git/**', '**/node_modules/**'], // Remove the delay before rebuilding once the first file changed aggregateTimeout: 0, }); From 9dc0463ffbb6922bcc11ef8ce19f566988f28a48 Mon Sep 17 00:00:00 2001 From: "zhanghang.heal" Date: Wed, 27 Nov 2024 15:31:28 +0800 Subject: [PATCH 2/2] chore: fix ut --- .../tests/__snapshots__/default.test.ts.snap | 20 +++++++++++++++---- .../tests/__snapshots__/basic.test.ts.snap | 10 ++++++++-- .../tests/__snapshots__/builder.test.ts.snap | 5 ++++- .../tests/__snapshots__/default.test.ts.snap | 20 +++++++++++++++---- .../__snapshots__/environments.test.ts.snap | 10 ++++++++-- 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap b/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap index e53d075805..5404708ae3 100644 --- a/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap +++ b/packages/compat/webpack/tests/__snapshots__/default.test.ts.snap @@ -390,7 +390,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = ` ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -777,7 +780,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -1110,7 +1116,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe "target": "node", "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -1432,7 +1441,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; diff --git a/packages/core/tests/__snapshots__/basic.test.ts.snap b/packages/core/tests/__snapshots__/basic.test.ts.snap index 6b4cab5253..d6f4bed12b 100644 --- a/packages/core/tests/__snapshots__/basic.test.ts.snap +++ b/packages/core/tests/__snapshots__/basic.test.ts.snap @@ -30,7 +30,10 @@ exports[`plugin-basic > should apply basic config correctly in development 1`] = ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -59,7 +62,10 @@ exports[`plugin-basic > should apply basic config correctly in production 1`] = ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; diff --git a/packages/core/tests/__snapshots__/builder.test.ts.snap b/packages/core/tests/__snapshots__/builder.test.ts.snap index adafffdbb4..57769ea397 100644 --- a/packages/core/tests/__snapshots__/builder.test.ts.snap +++ b/packages/core/tests/__snapshots__/builder.test.ts.snap @@ -401,7 +401,10 @@ exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] = ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; diff --git a/packages/core/tests/__snapshots__/default.test.ts.snap b/packages/core/tests/__snapshots__/default.test.ts.snap index 048246fcd6..0308c824be 100644 --- a/packages/core/tests/__snapshots__/default.test.ts.snap +++ b/packages/core/tests/__snapshots__/default.test.ts.snap @@ -416,7 +416,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = ` ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -873,7 +876,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -1225,7 +1231,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe "target": "node", "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; @@ -1661,7 +1670,10 @@ exports[`tools.rspack > should match snapshot 1`] = ` ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, } `; diff --git a/packages/core/tests/__snapshots__/environments.test.ts.snap b/packages/core/tests/__snapshots__/environments.test.ts.snap index 50d33b5862..86af3ab29b 100644 --- a/packages/core/tests/__snapshots__/environments.test.ts.snap +++ b/packages/core/tests/__snapshots__/environments.test.ts.snap @@ -1528,7 +1528,10 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e ], "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, }, { @@ -1858,7 +1861,10 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e "target": "node", "watchOptions": { "aggregateTimeout": 0, - "ignored": /\\[\\\\\\\\/\\]\\(\\?:\\\\\\.git\\|node_modules\\)\\[\\\\\\\\/\\]/, + "ignored": [ + "**/.git/**", + "**/node_modules/**", + ], }, }, ]