@nativescript/vite 0.0.1-alpha.0

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 (73) hide show
  1. package/dist/configuration/angular.d.ts +4 -0
  2. package/dist/configuration/angular.js +30 -0
  3. package/dist/configuration/base.d.ts +4 -0
  4. package/dist/configuration/base.js +270 -0
  5. package/dist/configuration/old-without-merge-base.d.ts +13 -0
  6. package/dist/configuration/old-without-merge-base.js +249 -0
  7. package/dist/configuration/react.d.ts +4 -0
  8. package/dist/configuration/react.js +85 -0
  9. package/dist/configuration/solid.d.ts +4 -0
  10. package/dist/configuration/solid.js +48 -0
  11. package/dist/configuration/vue.d.ts +4 -0
  12. package/dist/configuration/vue.js +45 -0
  13. package/dist/helpers/commonjs-plugins.d.ts +6 -0
  14. package/dist/helpers/commonjs-plugins.js +75 -0
  15. package/dist/helpers/config-as-json.d.ts +2 -0
  16. package/dist/helpers/config-as-json.js +35 -0
  17. package/dist/helpers/css-tree.d.ts +4 -0
  18. package/dist/helpers/css-tree.js +21 -0
  19. package/dist/helpers/dynamic-import-plugin.d.ts +4 -0
  20. package/dist/helpers/dynamic-import-plugin.js +62 -0
  21. package/dist/helpers/external-configs.d.ts +6 -0
  22. package/dist/helpers/external-configs.js +33 -0
  23. package/dist/helpers/flavor.d.ts +5 -0
  24. package/dist/helpers/flavor.js +40 -0
  25. package/dist/helpers/global-defines.d.ts +14 -0
  26. package/dist/helpers/global-defines.js +18 -0
  27. package/dist/helpers/main-entry.d.ts +5 -0
  28. package/dist/helpers/main-entry.js +75 -0
  29. package/dist/helpers/module-resolution.d.ts +1 -0
  30. package/dist/helpers/module-resolution.js +17 -0
  31. package/dist/helpers/nativescript-package-resolver.d.ts +5 -0
  32. package/dist/helpers/nativescript-package-resolver.js +139 -0
  33. package/dist/helpers/ns-cli-plugins.d.ts +19 -0
  34. package/dist/helpers/ns-cli-plugins.js +162 -0
  35. package/dist/helpers/package-platform-aliases.d.ts +4 -0
  36. package/dist/helpers/package-platform-aliases.js +83 -0
  37. package/dist/helpers/project.d.ts +23 -0
  38. package/dist/helpers/project.js +28 -0
  39. package/dist/helpers/resolver.d.ts +4 -0
  40. package/dist/helpers/resolver.js +31 -0
  41. package/dist/helpers/ts-config-paths.d.ts +4 -0
  42. package/dist/helpers/ts-config-paths.js +241 -0
  43. package/dist/helpers/utils.d.ts +29 -0
  44. package/dist/helpers/utils.js +101 -0
  45. package/dist/helpers/workers.d.ts +20 -0
  46. package/dist/helpers/workers.js +86 -0
  47. package/dist/hmr/hmr-angular.d.ts +1 -0
  48. package/dist/hmr/hmr-angular.js +34 -0
  49. package/dist/hmr/hmr-bridge.d.ts +18 -0
  50. package/dist/hmr/hmr-bridge.js +154 -0
  51. package/dist/hmr/hmr-client.d.ts +5 -0
  52. package/dist/hmr/hmr-client.js +93 -0
  53. package/dist/hmr/hmr-server.d.ts +20 -0
  54. package/dist/hmr/hmr-server.js +179 -0
  55. package/dist/index.d.ts +5 -0
  56. package/dist/index.js +5 -0
  57. package/dist/polyfills/mdn-data-at-rules.d.ts +7 -0
  58. package/dist/polyfills/mdn-data-at-rules.js +7 -0
  59. package/dist/polyfills/mdn-data-properties.d.ts +7 -0
  60. package/dist/polyfills/mdn-data-properties.js +7 -0
  61. package/dist/polyfills/mdn-data-syntaxes.d.ts +7 -0
  62. package/dist/polyfills/mdn-data-syntaxes.js +7 -0
  63. package/dist/polyfills/module.d.ts +17 -0
  64. package/dist/polyfills/module.js +29 -0
  65. package/dist/shims/react-reconciler-constants.d.ts +14 -0
  66. package/dist/shims/react-reconciler-constants.js +20 -0
  67. package/dist/shims/react-reconciler.d.ts +8 -0
  68. package/dist/shims/react-reconciler.js +14 -0
  69. package/dist/shims/set-value.d.ts +4 -0
  70. package/dist/shims/set-value.js +21 -0
  71. package/dist/transformers/NativeClass/index.d.ts +5 -0
  72. package/dist/transformers/NativeClass/index.js +46 -0
  73. package/package.json +31 -0
@@ -0,0 +1,48 @@
1
+ import solid from "vite-plugin-solid";
2
+ import path from "path";
3
+ import alias from "@rollup/plugin-alias";
4
+ import { fileURLToPath } from "node:url";
5
+ import { dirname, resolve } from "node:path";
6
+ import { getProjectRootPath } from "../helpers/project.js";
7
+ import { mergeConfig } from "vite";
8
+ import { baseConfig } from "./base.js";
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = dirname(__filename);
11
+ const projectRoot = getProjectRootPath();
12
+ const solidPath = path.resolve(projectRoot, "node_modules/solid-js");
13
+ const prod = !!process.env.production;
14
+ const plugins = [
15
+ {
16
+ ...alias({
17
+ entries: {
18
+ // Fix the web alias - it should NOT point to web/dist but to the main dist
19
+ "solid-js/web": resolve(solidPath, `web/dist/${prod ? "web" : "dev"}.js`),
20
+ // Alias solid-js modules to proper locations
21
+ "solid-js/universal": resolve(solidPath, `universal/dist/${prod ? "universal" : "dev"}.js`),
22
+ "solid-js/store": resolve(solidPath, `store/dist/${prod ? "store" : "dev"}.js`),
23
+ "solid-js": resolve(solidPath, `dist/${prod ? "solid" : "dev"}.js`),
24
+ },
25
+ }),
26
+ enforce: "pre",
27
+ },
28
+ // Enable SolidJS support with NativeScript configuration
29
+ solid({
30
+ // Configure for development
31
+ dev: !prod,
32
+ // Enable HMR for development
33
+ hot: !prod,
34
+ // Configure solid compiler options for NativeScript
35
+ solid: {
36
+ // Use universal instead of dom for NativeScript compatibility
37
+ generate: "universal",
38
+ hydratable: false,
39
+ // Use the NativeScript community SolidJS renderer
40
+ moduleName: "@nativescript-community/solid-js",
41
+ },
42
+ }),
43
+ ];
44
+ export const solidConfig = ({ mode }) => {
45
+ return mergeConfig(baseConfig({ mode }), {
46
+ plugins,
47
+ });
48
+ };
@@ -0,0 +1,4 @@
1
+ import { type UserConfig } from "vite";
2
+ export declare const vueConfig: ({ mode }: {
3
+ mode: any;
4
+ }) => UserConfig;
@@ -0,0 +1,45 @@
1
+ import vue from "@vitejs/plugin-vue";
2
+ import vueJsx from "@vitejs/plugin-vue-jsx";
3
+ import path from "path";
4
+ import alias from "@rollup/plugin-alias";
5
+ import { fileURLToPath } from "node:url";
6
+ import { dirname, resolve } from "node:path";
7
+ import { mergeConfig } from "vite";
8
+ import { baseConfig } from "./base.js";
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = dirname(__filename);
11
+ const plugins = [
12
+ {
13
+ ...alias({
14
+ entries: {
15
+ vue: "nativescript-vue",
16
+ "set-value": resolve(__dirname, "../shims/set-value.js"),
17
+ },
18
+ }),
19
+ enforce: "pre",
20
+ },
21
+ // Enable Vue Single File Component support
22
+ vue({
23
+ // NativeScript projects often use <script setup lang="ts">
24
+ script: {
25
+ defineModel: true,
26
+ propsDestructure: true,
27
+ },
28
+ // Keep template compilation basic; transform asset URLs is not needed for NS
29
+ template: {
30
+ transformAssetUrls: false,
31
+ compilerOptions: {
32
+ // Only treat real web custom elements (hyphenated) as custom.
33
+ // DO NOT match PascalCase NativeScript tags.
34
+ isCustomElement: (tag) => tag.includes("-"),
35
+ },
36
+ },
37
+ }),
38
+ // Optional: allow JSX/TSX in Vue components if used
39
+ vueJsx(),
40
+ ];
41
+ export const vueConfig = ({ mode }) => {
42
+ return mergeConfig(baseConfig({ mode }), {
43
+ plugins,
44
+ });
45
+ };
@@ -0,0 +1,6 @@
1
+ export declare const commonjsPlugins: {
2
+ name: string;
3
+ enforce: string;
4
+ resolveId(id: any): any;
5
+ load(id: any): string;
6
+ }[];
@@ -0,0 +1,75 @@
1
+ // Support various @nativescript/core transient commonjs dependency cases
2
+ export const commonjsPlugins = [
3
+ // Fix source-map-js subpath imports for css-tree compatibility
4
+ {
5
+ name: "source-map-js-subpath-compat",
6
+ enforce: "pre",
7
+ resolveId(id) {
8
+ if (id === "source-map-js/lib/source-map-generator.js") {
9
+ return "\0source-map-generator-virtual";
10
+ }
11
+ return null;
12
+ },
13
+ load(id) {
14
+ if (id === "\0source-map-generator-virtual") {
15
+ // Import the main source-map-js package and extract SourceMapGenerator
16
+ return `
17
+ import * as sourceMapJs from 'source-map-js';
18
+ const { SourceMapGenerator } = sourceMapJs;
19
+ export { SourceMapGenerator };
20
+ `;
21
+ }
22
+ return null;
23
+ },
24
+ },
25
+ // Fix html-entities ESM compatibility issue
26
+ {
27
+ name: "html-entities-compat",
28
+ enforce: "pre",
29
+ resolveId(id) {
30
+ if (id === "html-entities") {
31
+ return id;
32
+ }
33
+ return null;
34
+ },
35
+ load(id) {
36
+ if (id === "html-entities") {
37
+ // html-entities exports: exports.encode = encode; exports.decode = decode; exports.decodeEntity = decodeEntity;
38
+ return `
39
+ import * as htmlEntitiesModule from 'html-entities/lib/index.js';
40
+ export const encode = htmlEntitiesModule.encode;
41
+ export const decode = htmlEntitiesModule.decode;
42
+ export const decodeEntity = htmlEntitiesModule.decodeEntity;
43
+ export default htmlEntitiesModule;
44
+ `;
45
+ }
46
+ return null;
47
+ },
48
+ },
49
+ // Fix fast-xml-parser ESM compatibility issue
50
+ {
51
+ name: "fast-xml-parser-compat",
52
+ enforce: "pre",
53
+ resolveId(id) {
54
+ if (id === "fast-xml-parser") {
55
+ return id;
56
+ }
57
+ return null;
58
+ },
59
+ load(id) {
60
+ if (id === "fast-xml-parser") {
61
+ // fast-xml-parser exports: exports.XMLParser = XMLParser; exports.XMLBuilder = XMLBuilder; exports.XMLValidator = XMLValidator; etc.
62
+ return `
63
+ import * as fastXmlParser from 'fast-xml-parser/src/fxp.js';
64
+ export const XMLParser = fastXmlParser.XMLParser;
65
+ export const XMLBuilder = fastXmlParser.XMLBuilder;
66
+ export const XMLValidator = fastXmlParser.XMLValidator;
67
+ export const X2jOptions = fastXmlParser.X2jOptions;
68
+ export const J2xOptions = fastXmlParser.J2xOptions;
69
+ export default fastXmlParser;
70
+ `;
71
+ }
72
+ return null;
73
+ },
74
+ },
75
+ ];
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from "vite";
2
+ export default function nsConfigAsJsonPlugin(): Plugin;
@@ -0,0 +1,35 @@
1
+ import { nsConfigToJson } from "./utils.js";
2
+ const nsConfigVirtualId = "\0nsvite:nsconfig-json";
3
+ export default function nsConfigAsJsonPlugin() {
4
+ // will hold your parsed config object
5
+ let configObject;
6
+ return {
7
+ name: "nsvite-nsconfig-as-json",
8
+ // 1. Intercept imports of "~/package.json"
9
+ resolveId(source) {
10
+ if (source === "~/package.json") {
11
+ return nsConfigVirtualId;
12
+ }
13
+ return null;
14
+ },
15
+ // 2. When Vite asks us to load that virtual ID...
16
+ load(id) {
17
+ if (id === nsConfigVirtualId) {
18
+ configObject = nsConfigToJson();
19
+ // c) Return an ESM wrapper so Vite can import it at build‑time
20
+ return `export default ${JSON.stringify(configObject)};`;
21
+ }
22
+ return null;
23
+ },
24
+ // 3. After Rollup has generated all chunks, emit a package.json asset
25
+ // into the output directory (dist/ by default)
26
+ generateBundle(_options, _bundle) {
27
+ const json = JSON.stringify(configObject, null, 2);
28
+ this.emitFile({
29
+ type: "asset",
30
+ fileName: "package.json",
31
+ source: json,
32
+ });
33
+ },
34
+ };
35
+ }
@@ -0,0 +1,4 @@
1
+ export declare const aliasCssTree: {
2
+ find: string;
3
+ replacement: string;
4
+ }[];
@@ -0,0 +1,21 @@
1
+ import path from "path";
2
+ import { __dirname } from './project.js';
3
+ export const aliasCssTree = [
4
+ // Node.js built-ins and mdn-data polyfills for css-tree
5
+ {
6
+ find: "module",
7
+ replacement: path.resolve(__dirname, "../polyfills/module.js"),
8
+ },
9
+ {
10
+ find: "mdn-data/css/properties.json",
11
+ replacement: path.resolve(__dirname, "../polyfills/mdn-data-properties.js"),
12
+ },
13
+ {
14
+ find: "mdn-data/css/syntaxes.json",
15
+ replacement: path.resolve(__dirname, "../polyfills/mdn-data-syntaxes.js"),
16
+ },
17
+ {
18
+ find: "mdn-data/css/at-rules.json",
19
+ replacement: path.resolve(__dirname, "../polyfills/mdn-data-at-rules.js"),
20
+ },
21
+ ];
@@ -0,0 +1,4 @@
1
+ export declare function dynamicImportPlugin(): {
2
+ name: string;
3
+ generateBundle(options: any, bundle: any): void;
4
+ };
@@ -0,0 +1,62 @@
1
+ // Fix NativeScript dynamic imports by transforming paths and simplifying __vitePreload
2
+ // Vite auto adds __vitePreload which includes browser APIs we don't need.
3
+ // Note: ideally build.modulePreload = false in build settings would fix this
4
+ // by simply removing the existence of __vitePreload in the bundle.
5
+ // However, this appears to be a known Vite issue: https://github.com/vitejs/vite/issues/13952
6
+ // Keep issue in mind for future Vite updates as may be able to remove this eventually.
7
+ export function dynamicImportPlugin() {
8
+ return {
9
+ name: "nativescript-dynamic-import-fix",
10
+ generateBundle(options, bundle) {
11
+ for (const [fileName, chunk] of Object.entries(bundle)) {
12
+ if (chunk.type === "chunk") {
13
+ let hasChanges = false;
14
+ // 1. Transform all relative import paths from ./ to ~/
15
+ if (chunk.code.includes("import('./")) {
16
+ chunk.code = chunk.code.replace(/import\(['"]\.\/([^'"]*)['"]\)/g, "import('~/$1')");
17
+ hasChanges = true;
18
+ }
19
+ // 2. Replace __vitePreload with simple implementation
20
+ if (chunk.code.includes("__vitePreload")) {
21
+ const vitePreloadStart = chunk.code.indexOf("const __vitePreload = function preload");
22
+ if (vitePreloadStart !== -1) {
23
+ // Find the matching closing brace by counting braces
24
+ let braceCount = 0;
25
+ let functionStart = chunk.code.indexOf("{", vitePreloadStart);
26
+ let i = functionStart;
27
+ while (i < chunk.code.length) {
28
+ if (chunk.code[i] === "{")
29
+ braceCount++;
30
+ else if (chunk.code[i] === "}") {
31
+ braceCount--;
32
+ if (braceCount === 0) {
33
+ // Found the end of the function
34
+ const functionEnd = i + 1;
35
+ const before = chunk.code.substring(0, vitePreloadStart);
36
+ const after = chunk.code.substring(functionEnd);
37
+ // Simple implementation that just calls baseModule()
38
+ const replacement = `const __vitePreload = function preload(baseModule, deps, importerUrl) {
39
+ return baseModule().catch(err => {
40
+ console.error("Dynamic import error:", err);
41
+ throw err;
42
+ });
43
+ }`;
44
+ chunk.code = before + replacement + after;
45
+ hasChanges = true;
46
+ break;
47
+ }
48
+ }
49
+ i++;
50
+ }
51
+ }
52
+ }
53
+ // if (hasChanges) {
54
+ // console.log(
55
+ // `Fixed NativeScript dynamic imports in: ${fileName}`,
56
+ // );
57
+ // }
58
+ }
59
+ }
60
+ },
61
+ };
62
+ }
@@ -0,0 +1,6 @@
1
+ import type { UserConfig } from 'vite';
2
+ export declare const externalConfigMerges: UserConfig[];
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare function applyExternalConfigs(): void;
@@ -0,0 +1,33 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import { createRequire } from "module";
4
+ // import { pathToFileURL } from 'url';
5
+ import { getAllDependencies, getDependencyPath } from './utils.js';
6
+ const require = createRequire(import.meta.url);
7
+ export const externalConfigMerges = [];
8
+ /**
9
+ * @internal
10
+ */
11
+ export function applyExternalConfigs() {
12
+ for (const dependency of getAllDependencies()) {
13
+ const packagePath = getDependencyPath(dependency);
14
+ if (!packagePath) {
15
+ continue;
16
+ }
17
+ const configPath = path.join(packagePath, 'nativescript.vite.mjs');
18
+ if (fs.existsSync(configPath)) {
19
+ console.log(`Discovered external config: ${configPath}`);
20
+ try {
21
+ const externalModule = require(configPath);
22
+ const externalConfig = externalModule?.default ?? externalModule;
23
+ externalConfigMerges.push(externalConfig());
24
+ }
25
+ catch (err) {
26
+ console.warn(`
27
+ Unable to apply config: ${configPath}.
28
+ Error is: ${err}
29
+ `);
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Utility to determine the project flavor based on installed dependencies
3
+ * (vue, angular, react, svelete, typescript, javascript...)
4
+ */
5
+ export declare function determineProjectFlavor(): string | false;
@@ -0,0 +1,40 @@
1
+ // import { defaultConfigs } from '..';
2
+ import { getAllDependencies } from "./utils.js";
3
+ /**
4
+ * Utility to determine the project flavor based on installed dependencies
5
+ * (vue, angular, react, svelete, typescript, javascript...)
6
+ */
7
+ export function determineProjectFlavor() {
8
+ const dependencies = getAllDependencies();
9
+ if (dependencies.includes("nativescript-vue")) {
10
+ return "vue";
11
+ }
12
+ if (dependencies.includes("@nativescript/angular")) {
13
+ return "angular";
14
+ }
15
+ if (dependencies.includes("react-nativescript")) {
16
+ return "react";
17
+ }
18
+ if (dependencies.includes("@nativescript-community/solid-js") ||
19
+ dependencies.includes("solid-js")) {
20
+ return "solid";
21
+ }
22
+ if (dependencies.includes("svelte-native") ||
23
+ dependencies.includes("@nativescript-community/svelte-native")) {
24
+ return "svelte";
25
+ }
26
+ // the order is important - angular, react, and svelte also include these deps
27
+ // but should return prior to this condition!
28
+ if (dependencies.includes("@nativescript/core") &&
29
+ dependencies.includes("typescript")) {
30
+ return "typescript";
31
+ }
32
+ if (dependencies.includes("@nativescript/core")) {
33
+ return "javascript";
34
+ }
35
+ console.info(`
36
+ Could not determine project flavor.
37
+ Please use webpack.useConfig('<flavor>') to explicitly set the base config.
38
+ `);
39
+ return false;
40
+ }
@@ -0,0 +1,14 @@
1
+ export declare function getGlobalDefines(platform: string, targetMode: string): {
2
+ __ANDROID__: string;
3
+ __IOS__: string;
4
+ __VISIONOS__: string;
5
+ __APPLE__: string;
6
+ __DEV__: string;
7
+ __COMMONJS__: boolean;
8
+ __NS_WEBPACK__: boolean;
9
+ __NS_ENV_VERBOSE__: boolean;
10
+ __CSS_PARSER__: string;
11
+ __UI_USE_XML_PARSER__: boolean;
12
+ __UI_USE_EXTERNAL_RENDERER__: boolean;
13
+ __TEST__: boolean;
14
+ };
@@ -0,0 +1,18 @@
1
+ export function getGlobalDefines(platform, targetMode) {
2
+ return {
3
+ // Define platform flags for runtime checks
4
+ __ANDROID__: JSON.stringify(platform === "android"),
5
+ __IOS__: JSON.stringify(platform === "ios"),
6
+ __VISIONOS__: JSON.stringify(platform === "visionos"),
7
+ __APPLE__: JSON.stringify(platform === "ios" || platform === "visionos"),
8
+ __DEV__: JSON.stringify(targetMode === "development"),
9
+ __COMMONJS__: false,
10
+ __NS_WEBPACK__: true,
11
+ __NS_ENV_VERBOSE__: !!process.env.verbose,
12
+ __CSS_PARSER__: JSON.stringify("css-tree"),
13
+ __UI_USE_XML_PARSER__: true,
14
+ __UI_USE_EXTERNAL_RENDERER__: false,
15
+ // various ecosystems use this global (react for example)
16
+ __TEST__: false,
17
+ };
18
+ }
@@ -0,0 +1,5 @@
1
+ export declare function mainEntryPlugin(cliFlags: any, debug?: boolean): {
2
+ name: string;
3
+ resolveId(id: any): string;
4
+ load(id: any): string;
5
+ };
@@ -0,0 +1,75 @@
1
+ import { getPackageJson, getProjectFilePath, getProjectRootPath, } from "./project.js";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ const projectRoot = getProjectRootPath();
5
+ // main entry
6
+ const packageJson = getPackageJson();
7
+ const mainEntry = getProjectFilePath(packageJson.main);
8
+ // console.log("mainEntry:", mainEntry);
9
+ // hmr client
10
+ const hmrClientPath = getProjectFilePath("./node_modules/@nativescript/vite/dist/hmr/hmr-client.js");
11
+ const hmrClientExists = fs.existsSync(hmrClientPath);
12
+ // console.log("hmrClientPath:", hmrClientPath);
13
+ // console.log("hmrClientExists:", hmrClientExists);
14
+ // Check if polyfills file exists
15
+ const polyfillsPath = getProjectFilePath("src/polyfills.ts");
16
+ const polyfillsExists = fs.existsSync(polyfillsPath);
17
+ // console.log("polyfillsPath:", polyfillsPath);
18
+ // console.log("polyfillsExists:", polyfillsExists);
19
+ const VIRTUAL_ID = 'virtual:entry-with-polyfills';
20
+ const RESOLVED = '\0' + VIRTUAL_ID;
21
+ export function mainEntryPlugin(cliFlags, debug) {
22
+ return {
23
+ name: "main-entry",
24
+ resolveId(id) {
25
+ if (id === VIRTUAL_ID) {
26
+ return RESOLVED;
27
+ }
28
+ return null;
29
+ },
30
+ load(id) {
31
+ if (id === RESOLVED) {
32
+ let imports = "";
33
+ if (polyfillsExists) {
34
+ imports += `import '${polyfillsPath}';\n`;
35
+ }
36
+ // Import WebSocket support for HMR in development
37
+ if (debug && cliFlags.hmr) {
38
+ imports += `import '${hmrClientPath}';\n`;
39
+ }
40
+ // Import inspector modules for debugging in development
41
+ if (debug) {
42
+ imports += `import '@nativescript/core/inspector_modules';\n`;
43
+ }
44
+ // Import CSS and apply via Application.addCss before main entry
45
+ const appCssPath = path.resolve(projectRoot, "src/app.css");
46
+ if (fs.existsSync(appCssPath)) {
47
+ imports += `
48
+ // Import and apply global CSS
49
+ import appCssContent from './src/app.css?inline';
50
+ import { Application } from '@nativescript/core';
51
+
52
+ if (typeof global !== 'undefined' && appCssContent) {
53
+ try {
54
+ // Just testing logs if needed
55
+ // console.log('🎨 CSS content length:', appCssContent.length);
56
+ // console.log('🎨 CSS content preview:', appCssContent.substring(0, 200) + '...');
57
+
58
+ Application.addCss(appCssContent);
59
+ // console.log('🎨 Global CSS applied');
60
+ } catch (error) {
61
+ console.error('Error applying CSS:', error);
62
+ }
63
+ }
64
+ `;
65
+ }
66
+ imports += `import '${mainEntry}';`;
67
+ if (debug) {
68
+ console.log("🔄 Virtual entry imports:", imports);
69
+ }
70
+ return imports;
71
+ }
72
+ return null;
73
+ },
74
+ };
75
+ }
@@ -0,0 +1 @@
1
+ export declare function findPackageInNodeModules(packageName: string, startDir: string): string;
@@ -0,0 +1,17 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ // Node.js-style module resolution: walk up directory tree looking for node_modules
4
+ export function findPackageInNodeModules(packageName, startDir) {
5
+ let currentDir = startDir;
6
+ while (currentDir !== path.dirname(currentDir)) {
7
+ // Stop at filesystem root
8
+ const nodeModulesDir = path.join(currentDir, "node_modules");
9
+ const packagePath = path.join(nodeModulesDir, packageName);
10
+ if (fs.existsSync(packagePath)) {
11
+ return packagePath;
12
+ }
13
+ // Move up one directory
14
+ currentDir = path.dirname(currentDir);
15
+ }
16
+ return null;
17
+ }
@@ -0,0 +1,5 @@
1
+ export declare function nativescriptPackageResolver(platform: string): {
2
+ name: string;
3
+ enforce: string;
4
+ resolveId(id: any, importer: any): any;
5
+ };