diff --git a/host/resolver.ts b/host/resolver.ts index 30d8c7a0..6cff232c 100644 --- a/host/resolver.ts +++ b/host/resolver.ts @@ -1,13 +1,10 @@ import { parse, join } from "path"; import { statSync } from "fs"; -export function getResolver(platforms: string[], explicitResolve: string[] = []) { - const platformSpecificExt = [".ts", ".js", ".scss", ".less", ".css", ".html", ".xml", ".vue", ".json"]; - const nsPackageFilters = [ - 'nativescript', - 'tns', - 'ns' - ]; +export function getResolver(platforms: string[], explicitResolve?: string[], nsPackageFilters?: string[], platformSpecificExt?: string[]) { + explicitResolve = explicitResolve || []; + nsPackageFilters = nsPackageFilters || ['nativescript', 'tns', 'ns']; + platformSpecificExt = platformSpecificExt || [".ts", ".js", ".scss", ".less", ".css", ".html", ".xml", ".vue", ".json"]; return function (path: string) { const nmIndex = path.lastIndexOf('node_modules'); @@ -16,7 +13,7 @@ export function getResolver(platforms: string[], explicitResolve: string[] = []) const subPath = path.substr(nmIndex + 'node_modules'.length).replace(/\\/g, '/'); const shouldResolve = explicitResolve.length && explicitResolve.some(packageName => subPath.indexOf(packageName) !== -1); const pathParts = subPath.split(/[/\-_]/); - + if (!shouldResolve && pathParts.every(p => nsPackageFilters.every(f => f !== p))) { return path; }