From 216eaf935da870f0a1a1b14f2b852f879d467710 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sun, 15 Sep 2024 09:12:12 +0200 Subject: [PATCH] fix: Fix issues with conflictDependency that have two or more layers (#8481) --- .changeset/quick-vans-sip.md | 5 ++++ .../app-builder-lib/src/util/appFileCopier.ts | 23 ++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 .changeset/quick-vans-sip.md diff --git a/.changeset/quick-vans-sip.md b/.changeset/quick-vans-sip.md new file mode 100644 index 00000000000..451a3759804 --- /dev/null +++ b/.changeset/quick-vans-sip.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +fix: Fix issues with conflictDependency that have two or more layers diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index 3c585870c07..93a4a645693 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -197,24 +197,25 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag // use main matcher patterns, so, user can exclude some files !node_modules/xxxx return path.dirname(parentDir) } - for (const info of deps) { - const source = info.dir - const destination = path.join(mainMatcher.to, NODE_MODULES, info.name) + const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => { + const source = dep.dir const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns) const copier = new NodeModuleCopyHelper(matcher, platformPackager.info) - const files = await copier.collectNodeModules(info, nodeModuleExcludedExts) + const files = await copier.collectNodeModules(dep, nodeModuleExcludedExts) result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata }) - if (info.conflictDependency) { - for (const dep of info.conflictDependency) { - const source = dep.dir - const destination = path.join(mainMatcher.to, NODE_MODULES, info.name, NODE_MODULES, dep.name) - const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns) - const copier = new NodeModuleCopyHelper(matcher, platformPackager.info) - result[index++] = validateFileSet({ src: source, destination, files: await copier.collectNodeModules(dep, nodeModuleExcludedExts), metadata: copier.metadata }) + if (dep.conflictDependency) { + for (const c of dep.conflictDependency) { + await collectNodeModules(c, path.join(destination, NODE_MODULES, c.name)) } } } + + for (const dep of deps) { + const destination = path.join(mainMatcher.to, NODE_MODULES, dep.name) + await collectNodeModules(dep, destination) + } + return result }