11import { parse , join } from "path" ;
22import { statSync } from "fs" ;
33
4- export function getResolver ( platforms : string [ ] , explicitResolve : string [ ] = [ ] ) {
5- const platformSpecificExt = [ ".ts" , ".js" , ".scss" , ".less" , ".css" , ".html" , ".xml" , ".vue" , ".json" ] ;
6- const nsPackageFilters = [
7- 'nativescript' ,
8- 'tns' ,
9- 'ns'
10- ] ;
4+ export function getResolver ( platforms : string [ ] , options : { nsPackageFilters ?: string [ ] , explicitResolve ?: string [ ] , platformSpecificExt ?: string [ ] } = { } ) {
5+ options . nsPackageFilters = options . nsPackageFilters || [ 'nativescript' , 'tns' , 'ns' ] ;
6+ options . explicitResolve = options . explicitResolve || [ ] ;
7+ options . platformSpecificExt = options . platformSpecificExt || [ ".ts" , ".js" , ".scss" , ".less" , ".css" , ".html" , ".xml" , ".vue" , ".json" ] ;
8+
9+ const { nsPackageFilters, explicitResolve, platformSpecificExt } = options ;
1110
1211 return function ( path : string ) {
1312 const nmIndex = path . lastIndexOf ( 'node_modules' ) ;
@@ -16,7 +15,7 @@ export function getResolver(platforms: string[], explicitResolve: string[] = [])
1615 const subPath = path . substr ( nmIndex + 'node_modules' . length ) . replace ( / \\ / g, '/' ) ;
1716 const shouldResolve = explicitResolve . length && explicitResolve . some ( packageName => subPath . indexOf ( packageName ) !== - 1 ) ;
1817 const pathParts = subPath . split ( / [ / \- _ ] / ) ;
19-
18+
2019 if ( ! shouldResolve && pathParts . every ( p => nsPackageFilters . every ( f => f !== p ) ) ) {
2120 return path ;
2221 }
0 commit comments