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

Commit 4f3e8a6

Browse files
feat: allow angular resolver configuration via webpack.config
1 parent e2714f2 commit 4f3e8a6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: host/resolver.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
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[], 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

Comments
 (0)