Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit f9ccc30

Browse files
Merge pull request #802 from NativeScript/vgeorgiev/resolver
feat: allow angular resolver configuration via webpack.config
2 parents e2714f2 + c9fc731 commit f9ccc30

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

host/resolver.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { parse, join } from "path";
22
import { 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[], explicitResolve?: string[], nsPackageFilters?: string[], platformSpecificExt?: string[]) {
5+
explicitResolve = explicitResolve || [];
6+
nsPackageFilters = nsPackageFilters || ['nativescript', 'tns', 'ns'];
7+
platformSpecificExt = platformSpecificExt || [".ts", ".js", ".scss", ".less", ".css", ".html", ".xml", ".vue", ".json"];
118

129
return function (path: string) {
1310
const nmIndex = path.lastIndexOf('node_modules');
@@ -16,7 +13,7 @@ export function getResolver(platforms: string[], explicitResolve: string[] = [])
1613
const subPath = path.substr(nmIndex + 'node_modules'.length).replace(/\\/g, '/');
1714
const shouldResolve = explicitResolve.length && explicitResolve.some(packageName => subPath.indexOf(packageName) !== -1);
1815
const pathParts = subPath.split(/[/\-_]/);
19-
16+
2017
if (!shouldResolve && pathParts.every(p => nsPackageFilters.every(f => f !== p))) {
2118
return path;
2219
}

0 commit comments

Comments
 (0)