@@ -188,11 +188,19 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag
188
188
const result = new Array < ResolvedFileSet > ( )
189
189
let index = 0
190
190
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
+ }
191
200
for ( const info of deps ) {
192
201
const source = info . dir
193
202
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 )
196
204
const copier = new NodeModuleCopyHelper ( matcher , platformPackager . info )
197
205
const files = await copier . collectNodeModules ( info , nodeModuleExcludedExts )
198
206
result [ index ++ ] = validateFileSet ( { src : source , destination, files, metadata : copier . metadata } )
@@ -201,7 +209,7 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag
201
209
for ( const dep of info . conflictDependency ) {
202
210
const source = dep . dir
203
211
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 )
205
213
const copier = new NodeModuleCopyHelper ( matcher , platformPackager . info )
206
214
result [ index ++ ] = validateFileSet ( { src : source , destination, files : await copier . collectNodeModules ( dep , nodeModuleExcludedExts ) , metadata : copier . metadata } )
207
215
}
0 commit comments