MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / NativeScriptPlugin

Function NativeScriptPlugin

packages/vite/helpers/resolver.ts:5–38  ·  view source on GitHub ↗
(options: { platform: 'ios' | 'android' | 'visionos' })

Source from the content-addressed store, hash-verified

3import { resolveNativeScriptPlatformFile } from './utils.js';
4
5export default function NativeScriptPlugin(options: { platform: 'ios' | 'android' | 'visionos' }): Plugin {
6 return {
7 name: 'vite:nativescript',
8
9 resolveId(source, importer) {
10 const platform = options.platform;
11 if (!platform || !importer || source.startsWith('.') === false) {
12 return null;
13 }
14
15 const resolved = path.resolve(path.dirname(importer), source);
16 const extVariants = ['.ts', '.js'];
17
18 for (const ext of extVariants) {
19 const file = resolveNativeScriptPlatformFile(resolved + ext, platform);
20 if (file) {
21 return file;
22 }
23 }
24
25 return null;
26 },
27
28 transform(code, id) {
29 if (id.endsWith('.xml')) {
30 // Example: simple pass-through or custom transform for NativeScript view files
31 return {
32 code,
33 map: null,
34 };
35 }
36 },
37 };
38}

Callers 1

baseConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected