Skip to content

Commit f7daeb9

Browse files
authored
fix: return parent dir for local dependency (#8406)
1 parent 5ab2bee commit f7daeb9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.changeset/sixty-plants-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
return parent dir for local dependency

packages/app-builder-lib/src/util/appFileCopier.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,19 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag
188188
const result = new Array<ResolvedFileSet>()
189189
let index = 0
190190
const NODE_MODULES = "node_modules"
191+
const getRealSource = (source: string) => {
192+
const parentDir = path.dirname(source)
193+
// for the local node modules which is not in node modules
194+
if (!parentDir.endsWith(path.sep + NODE_MODULES)) {
195+
return parentDir
196+
}
197+
// use main matcher patterns, so, user can exclude some files !node_modules/xxxx
198+
return path.dirname(parentDir)
199+
}
191200
for (const info of deps) {
192201
const source = info.dir
193202
const destination = path.join(mainMatcher.to, NODE_MODULES, info.name)
194-
// use main matcher patterns, so, user can exclude some files !node_modules/xxxx
195-
const matcher = new FileMatcher(path.dirname(path.dirname(source)), destination, mainMatcher.macroExpander, mainMatcher.patterns)
203+
const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns)
196204
const copier = new NodeModuleCopyHelper(matcher, platformPackager.info)
197205
const files = await copier.collectNodeModules(info, nodeModuleExcludedExts)
198206
result[index++] = validateFileSet({ src: source, destination, files, metadata: copier.metadata })
@@ -201,7 +209,7 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag
201209
for (const dep of info.conflictDependency) {
202210
const source = dep.dir
203211
const destination = path.join(mainMatcher.to, NODE_MODULES, info.name, NODE_MODULES, dep.name)
204-
const matcher = new FileMatcher(path.dirname(path.dirname(source)), destination, mainMatcher.macroExpander, mainMatcher.patterns)
212+
const matcher = new FileMatcher(getRealSource(source), destination, mainMatcher.macroExpander, mainMatcher.patterns)
205213
const copier = new NodeModuleCopyHelper(matcher, platformPackager.info)
206214
result[index++] = validateFileSet({ src: source, destination, files: await copier.collectNodeModules(dep, nodeModuleExcludedExts), metadata: copier.metadata })
207215
}

0 commit comments

Comments
 (0)