@nstudio/nativescript-compiler 9.2.0-alpha.10 → 9.2.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/api/ir.js +7 -1
  2. package/dist/driver/cli.js +2 -0
  3. package/dist/driver/compile.js +22 -10
  4. package/dist/driver/unimplemented.js +15 -0
  5. package/dist/kotlin/access.js +22 -4
  6. package/dist/kotlin/arguments.js +5 -0
  7. package/dist/kotlin/builtins.js +0 -4
  8. package/dist/kotlin/calls.js +6 -2
  9. package/dist/kotlin/class-methods.js +9 -3
  10. package/dist/kotlin/components.js +13 -8
  11. package/dist/kotlin/core-api.js +2 -13
  12. package/dist/kotlin/declarations.js +2 -0
  13. package/dist/kotlin/expression-statements.js +5 -4
  14. package/dist/kotlin/functions.js +13 -4
  15. package/dist/kotlin/global-calls.js +11 -0
  16. package/dist/kotlin/literals.js +51 -5
  17. package/dist/kotlin/names.js +2 -2
  18. package/dist/kotlin/native/api.js +9 -1
  19. package/dist/kotlin/native/subclasses.js +4 -3
  20. package/dist/kotlin/native/types.js +8 -5
  21. package/dist/kotlin/operators.js +4 -1
  22. package/dist/kotlin/prototype-calls.js +5 -0
  23. package/dist/kotlin/render.js +62 -0
  24. package/dist/kotlin/statements.js +9 -0
  25. package/dist/kotlin/static-calls.js +4 -3
  26. package/dist/kotlin/types.js +6 -6
  27. package/dist/plugins/native-android.js +7 -3
  28. package/dist/plugins/native-ios.js +2 -0
  29. package/dist/plugins/source.js +73 -23
  30. package/dist/program/app-modules.js +91 -16
  31. package/dist/program/app-paths.js +80 -12
  32. package/dist/program/class-mixins.js +463 -0
  33. package/dist/program/core-facts.js +7 -0
  34. package/dist/program/glob.js +274 -0
  35. package/dist/program/platform.js +32 -4
  36. package/dist/program/program.js +212 -20
  37. package/dist/program/source-lines.js +4 -1
  38. package/dist/program/vite-plugins.js +144 -0
  39. package/dist/semantics/apis/globals.js +2 -2
  40. package/dist/semantics/apis/object.js +1 -0
  41. package/dist/semantics/apis/statics.js +6 -0
  42. package/dist/semantics/ast.js +20 -2
  43. package/dist/semantics/classes.js +36 -1
  44. package/dist/semantics/globals.js +3 -0
  45. package/dist/semantics/lang.js +13 -1
  46. package/dist/semantics/nullish.js +29 -11
  47. package/dist/semantics/refuse-receivers.js +3 -3
  48. package/dist/semantics/refuse-scope.js +2 -7
  49. package/dist/semantics/runtime.js +1 -0
  50. package/dist/semantics/states/value-states.js +1 -1
  51. package/dist/semantics/throws.js +1 -0
  52. package/dist/semantics/translator-methods.js +1 -1
  53. package/dist/semantics/types.js +21 -1
  54. package/dist/swift/access.js +25 -10
  55. package/dist/swift/arguments.js +10 -2
  56. package/dist/swift/assignment.js +12 -1
  57. package/dist/swift/builtins.js +0 -4
  58. package/dist/swift/calls.js +6 -2
  59. package/dist/swift/class-methods.js +3 -3
  60. package/dist/swift/components.js +28 -8
  61. package/dist/swift/construction.js +4 -0
  62. package/dist/swift/core-api.js +9 -12
  63. package/dist/swift/functions.js +13 -2
  64. package/dist/swift/generics.js +5 -1
  65. package/dist/swift/global-calls.js +2 -0
  66. package/dist/swift/literals.js +53 -6
  67. package/dist/swift/names.js +1 -1
  68. package/dist/swift/native/sdk-tables.js +52 -4
  69. package/dist/swift/native/sdk.js +9 -1
  70. package/dist/swift/operators.js +4 -1
  71. package/dist/swift/parameters.js +5 -2
  72. package/dist/swift/placement.js +42 -1
  73. package/dist/swift/prototype-calls.js +17 -2
  74. package/dist/swift/render.js +64 -0
  75. package/dist/swift/results.js +1 -1
  76. package/dist/swift/statements.js +9 -0
  77. package/dist/swift/static-calls.js +8 -3
  78. package/dist/swift/types.js +9 -9
  79. package/dist/targets/android/build.js +13 -9
  80. package/dist/targets/ios/build.js +11 -10
  81. package/dist/targets/ios/dependencies.js +12 -0
  82. package/dist/targets/resources.js +15 -1
  83. package/dist/template/plan.js +105 -8
  84. package/dist/types/adapter-api.d.ts +13 -0
  85. package/dist/types/ir.d.ts +47 -0
  86. package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +102 -7485
  87. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_view_common.kt +1 -3
  88. package/kit-android/generated/source-lines.json +1 -1
  89. package/kit-android/src/fromcore/kotlin/org/nativescript/kit/CoreBridge.kt +67 -1
  90. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Prototypes.kt +26 -0
  91. package/kit-apple/Overlays/xml-free/Core/ui.core.bindable.index.swift +4 -4
  92. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +24 -146
  93. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +0 -281
  94. package/kit-apple/Sources/NativeScriptKit/Core/{Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_91b5f3.swift → Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_fa18e1.swift} +28 -103
  95. package/kit-apple/Sources/NativeScriptKit/Core/__Namespace.Utils.swift +17 -15
  96. package/kit-apple/Sources/NativeScriptKit/Core/application-settings.index.ios.swift +8 -8
  97. package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +4 -4
  98. package/kit-apple/Sources/NativeScriptKit/Core/color.color-common.swift +7 -7
  99. package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +2 -1
  100. package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +1 -1
  101. package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +34 -244
  102. package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +1 -2
  103. package/kit-apple/Sources/NativeScriptKit/Core/ui.action-bar.index.ios.swift +3 -3
  104. package/kit-apple/Sources/NativeScriptKit/Core/ui.button.index.ios.swift +4 -4
  105. package/kit-apple/Sources/NativeScriptKit/Core/ui.content-view.index.swift +8 -8
  106. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.bindable.index.swift +4 -4
  107. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +8 -8
  108. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -3
  109. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-helper.view-helper-common.swift +7 -7
  110. package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +4 -4
  111. package/kit-apple/Sources/NativeScriptKit/Core/ui.html-view.index.ios.swift +4 -4
  112. package/kit-apple/Sources/NativeScriptKit/Core/ui.image.image-common.swift +2 -2
  113. package/kit-apple/Sources/NativeScriptKit/Core/ui.image.index.ios.swift +4 -4
  114. package/kit-apple/Sources/NativeScriptKit/Core/ui.label.index.ios.swift +4 -4
  115. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.absolute-layout.index.ios.swift +4 -4
  116. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.dock-layout.index.ios.swift +4 -4
  117. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +3 -3
  118. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.grid-layout.index.ios.swift +4 -4
  119. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.stack-layout.index.ios.swift +4 -4
  120. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.wrap-layout.index.ios.swift +4 -4
  121. package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +3 -3
  122. package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +4 -4
  123. package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +4 -4
  124. package/kit-apple/Sources/NativeScriptKit/Core/ui.scroll-view.index.ios.swift +4 -4
  125. package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +4 -4
  126. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +1 -1
  127. package/kit-apple/Sources/NativeScriptKit/Core/ui.tab-view.index.ios.swift +4 -4
  128. package/kit-apple/Sources/NativeScriptKit/Core/utils.common.swift +9 -9
  129. package/kit-apple/Sources/NativeScriptKit/Core/utils.layout-helper.index.ios.swift +10 -10
  130. package/kit-apple/Sources/NativeScriptKit/CoreBridge.swift +67 -1
  131. package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +4 -0
  132. package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +25 -0
  133. package/kit-apple/Sources/NativeScriptKit/Runtime/RegExp.swift +6 -0
  134. package/package.json +1 -1
  135. package/kit-apple/Sources/NativeScriptKit/Core/Object_toString_charAt_charCodeAt_concat_indexOf_lastIndexOf_and_44_more_fc25df.swift +0 -481
@@ -1,30 +1,105 @@
1
1
  import ts from 'typescript';
2
- import { existsSync, readFileSync } from 'node:fs';
2
+ import { existsSync, readFileSync, statSync } from 'node:fs';
3
3
  import { dirname, join, relative, resolve } from 'node:path';
4
+ import { globMatchedFiles } from "./glob.js";
4
5
  /**
5
- * The imports among `files`: relative specifiers and those the app's tsconfig `paths` alias (`aliased`), each completed
6
- * as the bundler does, the platform's own file (`thisPlatform`, `.ios.ts`) beside the shared one.
6
+ * The imports among `files`: relative specifiers and those the app's tsconfig `paths` / Vite config alias (`aliased`),
7
+ * each completed as the bundler does, the platform's own file (`thisPlatform`, `.ios.ts`) beside the shared one.
8
+ * Local monorepo workspace TypeScript sources outside `files` (and outside `node_modules`) are discovered transitively.
7
9
  */
8
- export function appImports(files, aliased, thisPlatform) {
9
- const out = { importsOf: new Map(), usedBy: new Map(), workerScripts: new Set() };
10
+ export function appImports(files, aliased, thisPlatform, appRoot = null, readSource = (f) => readFileSync(f, 'utf8')) {
11
+ const out = { importsOf: new Map(), usedBy: new Map(), workerScripts: new Set(), discovered: [] };
10
12
  const known = new Set(files);
11
- for (const f of files.filter((x) => /\.tsx?$/.test(x) && !x.endsWith('.d.ts'))) {
12
- const text = readFileSync(f, 'utf8');
13
- for (const m of text.matchAll(/(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|(new\s+Worker\s*\(\s*(?:new\s+URL\s*\(\s*)?)|\brequire\s*\(\s*)['"]([^'"\s]+)['"]/g)) {
14
- const target = m[2].startsWith('.') ? resolve(dirname(f), m[2]) : aliased(m[2]);
15
- if (!target)
13
+ const otherPlatform = thisPlatform === '.android.ts' ? /\.ios\.tsx?$/ : /\.android\.tsx?$/;
14
+ const isFile = (p) => existsSync(p) && statSync(p).isFile();
15
+ const queue = files.filter((x) => /\.tsx?$/.test(x) && !x.endsWith('.d.ts'));
16
+ const seen = new Set();
17
+ const link = (from, to, worker) => {
18
+ if (worker)
19
+ out.workerScripts.add(to);
20
+ else
21
+ out.usedBy.set(to, (out.usedBy.get(to) ?? new Set()).add(from));
22
+ out.importsOf.set(from, (out.importsOf.get(from) ?? new Set()).add(to));
23
+ };
24
+ const discover = (c) => {
25
+ if (known.has(c) || c.endsWith('.d.ts') || otherPlatform.test(c) || /[\\/]node_modules[\\/]/.test(c))
26
+ return false;
27
+ if (!/\.tsx?$/.test(c) || !isFile(c))
28
+ return false;
29
+ known.add(c);
30
+ out.discovered.push(c);
31
+ queue.push(c);
32
+ return true;
33
+ };
34
+ for (let i = 0; i < queue.length; i++) {
35
+ const f = queue[i];
36
+ if (seen.has(f))
37
+ continue;
38
+ seen.add(f);
39
+ const text = readSource(f);
40
+ const sf = ts.createSourceFile(f, text, ts.ScriptTarget.Latest, false);
41
+ const specs = [];
42
+ const visitSpec = (n) => {
43
+ if (ts.isImportDeclaration(n) && ts.isStringLiteralLike(n.moduleSpecifier)) {
44
+ const clause = n.importClause;
45
+ const allTypeOnly = !!clause?.isTypeOnly ||
46
+ (!!clause && !clause.name && !!clause.namedBindings && ts.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length > 0 && clause.namedBindings.elements.every((e) => e.isTypeOnly));
47
+ if (!allTypeOnly)
48
+ specs.push({ spec: n.moduleSpecifier.text, worker: false });
49
+ return;
50
+ }
51
+ if (ts.isExportDeclaration(n) && n.moduleSpecifier && ts.isStringLiteralLike(n.moduleSpecifier)) {
52
+ const allTypeOnly = n.isTypeOnly ||
53
+ (!!n.exportClause && ts.isNamedExports(n.exportClause) && n.exportClause.elements.length > 0 && n.exportClause.elements.every((e) => e.isTypeOnly));
54
+ if (!allTypeOnly)
55
+ specs.push({ spec: n.moduleSpecifier.text, worker: false });
56
+ return;
57
+ }
58
+ if (ts.isCallExpression(n)) {
59
+ if ((n.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(n.expression) && n.expression.text === 'require')) && n.arguments[0] && ts.isStringLiteralLike(n.arguments[0])) {
60
+ specs.push({ spec: n.arguments[0].text, worker: false });
61
+ }
62
+ }
63
+ else if (ts.isNewExpression(n) && ts.isIdentifier(n.expression) && n.expression.text === 'Worker' && n.arguments?.[0]) {
64
+ const arg0 = n.arguments[0];
65
+ const lit = ts.isStringLiteralLike(arg0) ? arg0 : ts.isNewExpression(arg0) && ts.isIdentifier(arg0.expression) && arg0.expression.text === 'URL' && arg0.arguments?.[0] && ts.isStringLiteralLike(arg0.arguments[0]) ? arg0.arguments[0] : undefined;
66
+ if (lit)
67
+ specs.push({ spec: lit.text, worker: true });
68
+ }
69
+ ts.forEachChild(n, visitSpec);
70
+ };
71
+ visitSpec(sf);
72
+ for (const { spec, worker } of specs) {
73
+ if (spec.includes('?'))
16
74
  continue;
17
- const base = target.replace(/\.(ts|js)$/, '');
75
+ const target = spec.startsWith('.') ? resolve(dirname(f), spec) : aliased(spec, f);
76
+ if (!target || /[\\/]node_modules[\\/]/.test(target))
77
+ continue;
78
+ const base = target.replace(/\.(tsx?|m?js)$/, '');
79
+ let matched = false;
18
80
  for (const c of [base + '.ts', base + thisPlatform, base + '.tsx', base + '/index.ts', `${base}/index${thisPlatform}`]) {
19
81
  if (!known.has(c))
20
82
  continue;
21
- if (m[1])
22
- out.workerScripts.add(c);
23
- else
24
- out.usedBy.set(c, (out.usedBy.get(c) ?? new Set()).add(f));
25
- out.importsOf.set(f, (out.importsOf.get(f) ?? new Set()).add(c));
83
+ link(f, c, worker);
84
+ matched = true;
85
+ }
86
+ if (matched)
87
+ continue;
88
+ // External monorepo workspace source (not under appDir): pick the platform file when present, else the shared source.
89
+ const external = /\.tsx?$/.test(target)
90
+ ? [target.replace(/\.ts$/, thisPlatform), target]
91
+ : [base + thisPlatform, base + '.ts', base + '.tsx', `${base}/index${thisPlatform}`, base + '/index.ts', base + '/index.tsx'];
92
+ for (const c of external) {
93
+ if (discover(c)) {
94
+ link(f, c, worker);
95
+ break;
96
+ }
26
97
  }
27
98
  }
99
+ for (const c of globMatchedFiles(text, f, appRoot)) {
100
+ if (known.has(c) || discover(c))
101
+ link(f, c, false);
102
+ }
28
103
  }
29
104
  return out;
30
105
  }
@@ -1,12 +1,61 @@
1
1
  import ts from 'typescript';
2
+ import { execFileSync } from 'node:child_process';
2
3
  import { existsSync, statSync } from 'node:fs';
3
- import { dirname, resolve, sep } from 'node:path';
4
+ import { dirname, isAbsolute, resolve, sep } from 'node:path';
4
5
  /** Packages whose resolution always belongs to the framework/core/kit rather than a monorepo tsconfig path alias. */
5
- const PACKAGE_ONLY = /^(@nativescript\/(core|types|types-ios|types-android|types-minimal|angular|vue|svelte|react|solid|webpack|vite|tailwind|android|ios)|@angular\/|vue|svelte|react|react-dom|solid-js|tslib|typescript)(\/|$)/;
6
+ const PACKAGE_ONLY = /^(@nativescript\/(core|types|types-ios|types-android|types-minimal|angular|vue|svelte|react|react-dom|solid|webpack|vite|tailwind|android|ios)|@angular\/|vue|svelte|react|react-dom|solid-js|tslib|typescript)(\/|$)/;
7
+ const viteAliasCache = new Map();
8
+ /** App-level `resolve.alias` entries from a Vite config (`vite.config.*`) that point to workspace TypeScript sources. */
9
+ function viteAliases(root) {
10
+ const cached = viteAliasCache.get(root);
11
+ if (cached)
12
+ return cached;
13
+ const configFile = ['vite.config.mts', 'vite.config.ts', 'vite.config.mjs', 'vite.config.js'].map((f) => resolve(root, f)).find(existsSync);
14
+ if (!configFile) {
15
+ viteAliasCache.set(root, []);
16
+ return [];
17
+ }
18
+ const out = [];
19
+ try {
20
+ const script = `
21
+ import { createRequire } from 'node:module';
22
+ import { pathToFileURL } from 'node:url';
23
+ const req = createRequire(${JSON.stringify(resolve(root, 'package.json'))});
24
+ const vite = await import(pathToFileURL(req.resolve('vite')).href);
25
+ const cfg = await vite.resolveConfig({ configFile: ${JSON.stringify(configFile)}, mode: 'production' }, 'build', 'production', 'production');
26
+ const list = (cfg.resolve?.alias ?? []).map((a) => ({
27
+ find: a.find instanceof RegExp ? { re: a.find.source, flags: a.find.flags } : a.find,
28
+ replacement: a.replacement,
29
+ }));
30
+ process.stdout.write('\\n__NS_VITE_ALIASES__' + JSON.stringify(list) + '__END__\\n');
31
+ `;
32
+ const stdout = execFileSync(process.execPath, ['--input-type=module', '-e', script], {
33
+ cwd: root,
34
+ stdio: ['ignore', 'pipe', 'ignore'],
35
+ env: { ...process.env, VITE_CONFIG_NATIVE_IGNORE_WARNING: 'true' },
36
+ timeout: 15_000,
37
+ }).toString('utf8');
38
+ const m = /__NS_VITE_ALIASES__([\s\S]*?)__END__/.exec(stdout);
39
+ if (m) {
40
+ for (const entry of JSON.parse(m[1])) {
41
+ const rep = entry.replacement;
42
+ if (!rep || !isAbsolute(rep) || rep.startsWith('/@fs/') || /[\\/]node_modules[\\/]/.test(rep))
43
+ continue;
44
+ const find = typeof entry.find === 'string' ? entry.find : new RegExp(entry.find.re, entry.find.flags);
45
+ out.push({ find, replacement: rep });
46
+ }
47
+ }
48
+ }
49
+ catch {
50
+ // Fall back cleanly to tsconfig paths if Vite cannot load in this environment.
51
+ }
52
+ viteAliasCache.set(root, out);
53
+ return out;
54
+ }
6
55
  /**
7
- * The `compilerOptions.paths` of the tsconfig.json nearest `from` (its `extends` followed), as the app's bundler applies
8
- * them to the app's own files: `~/app/x` is `<app>/src/app/x` for `"~/*": ["./src/*"]`, and monorepo shared TypeScript
9
- * aliases (such as `"@demo/shared": ["../../tools/demo/index.ts"]`) resolve to their workspace TypeScript sources.
56
+ * The `compilerOptions.paths` of the tsconfig.json nearest `from` (its `extends` followed), plus app-level Vite
57
+ * `resolve.alias` entries when a `vite.config.*` is present: `~/app/x` is `<app>/src/app/x` for `"~/*": ["./src/*"]`,
58
+ * and monorepo shared TypeScript aliases resolve to their workspace TypeScript sources.
10
59
  * A specifier targeting `node_modules`, a built JS package directory, or core/framework packages is undefined.
11
60
  */
12
61
  export function pathAliases(from) {
@@ -15,22 +64,41 @@ export function pathAliases(from) {
15
64
  if (existsSync(resolve(dir, 'tsconfig.json')))
16
65
  config = resolve(dir, 'tsconfig.json');
17
66
  else if (dirname(dir) === dir)
18
- return () => undefined;
67
+ break;
19
68
  }
20
- const options = ts.getParsedCommandLineOfConfigFile(config, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => { } })?.options;
21
- if (!options?.paths)
22
- return () => undefined;
23
- const root = dirname(config);
24
- const base = options.baseUrl ?? options.pathsBasePath ?? root;
25
- const patterns = Object.entries(options.paths).map(([pattern, targets]) => {
69
+ const root = config ? dirname(config) : resolve(from);
70
+ const vAliases = viteAliases(root);
71
+ const options = config ? ts.getParsedCommandLineOfConfigFile(config, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => { } })?.options : undefined;
72
+ const base = options?.baseUrl ?? options?.pathsBasePath ?? root;
73
+ const patterns = Object.entries(options?.paths ?? {}).map(([pattern, targets]) => {
26
74
  const star = pattern.indexOf('*');
27
75
  return { prefix: star < 0 ? pattern : pattern.slice(0, star), suffix: star < 0 ? null : pattern.slice(star + 1), targets };
28
76
  });
29
77
  // As TypeScript matches them: an exact pattern first, then the longest prefix.
30
78
  patterns.sort((a, b) => Number(a.suffix !== null) - Number(b.suffix !== null) || b.prefix.length - a.prefix.length);
79
+ if (!patterns.length && !vAliases.length)
80
+ return () => undefined;
31
81
  const isFile = (p) => existsSync(p) && statSync(p).isFile();
32
82
  const names = (path) => ['', '.ts', '.tsx', '.d.ts', '/index.ts', '/index.tsx'].some((x) => isFile(path + x)) || ['ios', 'android'].some((p) => isFile(`${path}.${p}.ts`) || isFile(`${path}/index.${p}.ts`));
33
83
  return (spec) => {
84
+ if (!PACKAGE_ONLY.test(spec)) {
85
+ for (const a of vAliases) {
86
+ if (typeof a.find === 'string') {
87
+ if (spec === a.find && names(a.replacement))
88
+ return a.replacement;
89
+ if (spec.startsWith(a.find + '/')) {
90
+ const sub = resolve(a.replacement, spec.slice(a.find.length + 1));
91
+ if (!/[\\/]node_modules[\\/]/.test(sub) && names(sub))
92
+ return sub;
93
+ }
94
+ }
95
+ else if (a.find.test(spec)) {
96
+ const rep = spec.replace(a.find, a.replacement);
97
+ if (isAbsolute(rep) && !/[\\/]node_modules[\\/]/.test(rep) && names(rep))
98
+ return rep;
99
+ }
100
+ }
101
+ }
34
102
  for (const p of patterns) {
35
103
  let star = '';
36
104
  if (p.suffix === null) {