From 0f7d5cc8a6cb05669b17aa359037f9d6848d823c Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Wed, 26 Jun 2024 12:00:04 +0800 Subject: [PATCH] fix: support compileDependencies in speedup mode --- .changeset/popular-buttons-behave.md | 5 +++++ packages/rspack-config/src/index.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/popular-buttons-behave.md diff --git a/.changeset/popular-buttons-behave.md b/.changeset/popular-buttons-behave.md new file mode 100644 index 0000000000..16320714b8 --- /dev/null +++ b/.changeset/popular-buttons-behave.md @@ -0,0 +1,5 @@ +--- +'@ice/rspack-config': patch +--- + +fix: support compileDendencies in speedup mode diff --git a/packages/rspack-config/src/index.ts b/packages/rspack-config/src/index.ts index 205a3441dd..b614513dde 100644 --- a/packages/rspack-config/src/index.ts +++ b/packages/rspack-config/src/index.ts @@ -169,7 +169,16 @@ const getConfig: GetConfig = async (options) => { if (!compileIncludes || compileIncludes?.length === 0) { excludeRule = 'node_modules'; } else if (!compileIncludes?.includes('node_modules') && compileIncludes?.length > 0) { - excludeRule = `node_modules[\\/](?!${compileIncludes.map((pkg: string) => { + const flattenIncludes = []; + compileIncludes.forEach((pkg) => { + if (typeof pkg === 'string') { + flattenIncludes.push(pkg); + } else { + // The RegExp type of pkg may include multiple source paths. + flattenIncludes.push(...pkg.source.split('|')); + } + }); + excludeRule = `node_modules[\\/](?!${flattenIncludes.map((pkg: string) => { return `${pkg}[\\/]|_${pkg.replace('/', '_')}@[^/]+[\\/]`; }).join('|')}).*`; }