@@ -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