From 4f3e8a640e502a76ef75435428db010d662e8de5 Mon Sep 17 00:00:00 2001 From: Ventsislav Georgiev Date: Fri, 15 Feb 2019 10:26:19 +0200 Subject: [PATCH 1/2] feat: allow angular resolver configuration via webpack.config --- host/resolver.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/host/resolver.ts b/host/resolver.ts index 30d8c7a0..f32fd50b 100644 --- a/host/resolver.ts +++ b/host/resolver.ts @@ -1,13 +1,12 @@ 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[], options: { nsPackageFilters?: string[], explicitResolve?: string[], platformSpecificExt?: string[] } = {}) { + options.nsPackageFilters = options.nsPackageFilters || ['nativescript', 'tns', 'ns']; + options.explicitResolve = options.explicitResolve || []; + options.platformSpecificExt = options.platformSpecificExt || [".ts", ".js", ".scss", ".less", ".css", ".html", ".xml", ".vue", ".json"]; + + const { nsPackageFilters, explicitResolve, platformSpecificExt } = options; return function (path: string) { const nmIndex = path.lastIndexOf('node_modules'); @@ -16,7 +15,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; } From c9fc73186a030bc2a2293ba012984ba8c8eb5098 Mon Sep 17 00:00:00 2001 From: Ventsislav Georgiev Date: Fri, 15 Feb 2019 11:41:35 +0200 Subject: [PATCH 2/2] feat: backwards compatible angular resolver options --- host/resolver.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/host/resolver.ts b/host/resolver.ts index f32fd50b..6cff232c 100644 --- a/host/resolver.ts +++ b/host/resolver.ts @@ -1,12 +1,10 @@ import { parse, join } from "path"; import { statSync } from "fs"; -export function getResolver(platforms: string[], options: { nsPackageFilters?: string[], explicitResolve?: string[], platformSpecificExt?: string[] } = {}) { - options.nsPackageFilters = options.nsPackageFilters || ['nativescript', 'tns', 'ns']; - options.explicitResolve = options.explicitResolve || []; - options.platformSpecificExt = options.platformSpecificExt || [".ts", ".js", ".scss", ".less", ".css", ".html", ".xml", ".vue", ".json"]; - - const { nsPackageFilters, explicitResolve, platformSpecificExt } = options; +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');