From 47a5773a1b93696ede654aeaac8c2fac2abcf1d0 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 15 Aug 2024 12:17:14 +0800 Subject: [PATCH] fix: support compileDependencies in speedup mode (#6925) --- .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 95c415203f..288e602a09 100644 --- a/packages/rspack-config/src/index.ts +++ b/packages/rspack-config/src/index.ts @@ -170,7 +170,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('|')}).*`; }