From f43b1f209379af8c85113ae2480f04e98ca10709 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 00:55:24 +0800 Subject: [PATCH 1/8] fix multiple conflic dependency map --- .../app-builder-lib/src/util/appFileCopier.ts | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index 3c585870c07..96c93271168 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -197,24 +197,27 @@ 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 matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns) - const copier = new NodeModuleCopyHelper(matcher, platformPackager.info) - const files = await copier.collectNodeModules(info, 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 }) - } + const collectNodeModules = async (dep: NodeModuleInfo, destination:string) => { + if(!dep.conflictDependency){ + 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(dep, nodeModuleExcludedExts) + result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata }) + return } + + for (const info of dep.conflictDependency) { + collectNodeModules(info, path.join(destination, NODE_MODULES, info.name)) + } + } + + for (const info of deps) { + const destination = path.join(mainMatcher.to, NODE_MODULES, info.name) + collectNodeModules(info, destination) + } + return result } From e7f69b7d99c234786e7b538a45b9c9c13b18139b Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 00:57:54 +0800 Subject: [PATCH 2/8] format --- packages/app-builder-lib/src/util/appFileCopier.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index 96c93271168..0e52047598b 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -197,8 +197,8 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag // use main matcher patterns, so, user can exclude some files !node_modules/xxxx return path.dirname(parentDir) } - const collectNodeModules = async (dep: NodeModuleInfo, destination:string) => { - if(!dep.conflictDependency){ + const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => { + if (!dep.conflictDependency) { const source = dep.dir const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns) const copier = new NodeModuleCopyHelper(matcher, platformPackager.info) @@ -208,14 +208,13 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag } for (const info of dep.conflictDependency) { - collectNodeModules(info, path.join(destination, NODE_MODULES, info.name)) + collectNodeModules(info, path.join(destination, NODE_MODULES, info.name)) } - } for (const info of deps) { - const destination = path.join(mainMatcher.to, NODE_MODULES, info.name) - collectNodeModules(info, destination) + const destination = path.join(mainMatcher.to, NODE_MODULES, info.name) + collectNodeModules(info, destination) } return result From 428c493d43c3d54bb7d6fefd1f661d781910b51d Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 00:59:53 +0800 Subject: [PATCH 3/8] fix with await --- packages/app-builder-lib/src/util/appFileCopier.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index 0e52047598b..f04b8f7b6bf 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -208,13 +208,13 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag } for (const info of dep.conflictDependency) { - collectNodeModules(info, path.join(destination, NODE_MODULES, info.name)) + await collectNodeModules(info, path.join(destination, NODE_MODULES, info.name)) } } for (const info of deps) { const destination = path.join(mainMatcher.to, NODE_MODULES, info.name) - collectNodeModules(info, destination) + await collectNodeModules(info, destination) } return result From 345c2037fddb73f55e9be948a34ecd1c06816ead Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 01:12:35 +0800 Subject: [PATCH 4/8] add changeset --- .changeset/quick-vans-sip.md | 5 +++++ 1 file changed, 5 insertions(+) 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 From a849142d53bad86620269d5703bdc4bb4acd0f90 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 01:24:57 +0800 Subject: [PATCH 5/8] add changeset --- packages/app-builder-lib/src/util/appFileCopier.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index f04b8f7b6bf..60ee7f5f1eb 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -198,7 +198,7 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag return path.dirname(parentDir) } const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => { - if (!dep.conflictDependency) { + if (dep.conflictDependency.length === 0) { const source = dep.dir const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns) const copier = new NodeModuleCopyHelper(matcher, platformPackager.info) @@ -207,14 +207,14 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag return } - for (const info of dep.conflictDependency) { - await collectNodeModules(info, path.join(destination, NODE_MODULES, info.name)) + for (const c of dep.conflictDependency) { + await collectNodeModules(c, path.join(destination, NODE_MODULES, c.name)) } } - for (const info of deps) { - const destination = path.join(mainMatcher.to, NODE_MODULES, info.name) - await collectNodeModules(info, destination) + for (const dep of deps) { + const destination = path.join(mainMatcher.to, NODE_MODULES, dep.name) + await collectNodeModules(dep, destination) } return result From cbc9d2fe467fdd1ba66959304511a92858531904 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 01:31:43 +0800 Subject: [PATCH 6/8] fix length --- packages/app-builder-lib/src/util/appFileCopier.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index 60ee7f5f1eb..eb75b91da12 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -198,7 +198,7 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag return path.dirname(parentDir) } const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => { - if (dep.conflictDependency.length === 0) { + if (!dep.conflictDependency || dep.conflictDependency.length === 0) { const source = dep.dir const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns) const copier = new NodeModuleCopyHelper(matcher, platformPackager.info) From 772e7c8b760ea0ea6678ac4bc217bf43e55a8a39 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 11:28:48 +0800 Subject: [PATCH 7/8] fix issue --- .../app-builder-lib/src/util/appFileCopier.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index eb75b91da12..ae2735365d1 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -198,18 +198,18 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag return path.dirname(parentDir) } const collectNodeModules = async (dep: NodeModuleInfo, destination: string) => { - if (!dep.conflictDependency || dep.conflictDependency.length === 0) { - 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(dep, nodeModuleExcludedExts) - result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata }) - return - } + 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(dep, nodeModuleExcludedExts) + result[index++] = validateFileSet({ src: source, destination, files, 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) { From 174649c7d063ee73658e5f76402bfd0fea5dfcf4 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sat, 14 Sep 2024 16:35:49 +0800 Subject: [PATCH 8/8] format code --- packages/app-builder-lib/src/util/appFileCopier.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/app-builder-lib/src/util/appFileCopier.ts b/packages/app-builder-lib/src/util/appFileCopier.ts index ae2735365d1..93a4a645693 100644 --- a/packages/app-builder-lib/src/util/appFileCopier.ts +++ b/packages/app-builder-lib/src/util/appFileCopier.ts @@ -205,11 +205,10 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata }) if (dep.conflictDependency) { - for (const c of dep.conflictDependency) { - await collectNodeModules(c, path.join(destination, NODE_MODULES, c.name)) - } + for (const c of dep.conflictDependency) { + await collectNodeModules(c, path.join(destination, NODE_MODULES, c.name)) + } } - } for (const dep of deps) {