@gjsify/vite-plugin-gjsify 0.4.35 → 0.4.36

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.
package/lib/index.d.ts CHANGED
@@ -36,3 +36,35 @@ export interface GjsifyBrowserOptions {
36
36
  */
37
37
  export declare function gjsifyBrowser(options?: GjsifyBrowserOptions): Plugin[];
38
38
  export default gjsifyBrowser;
39
+ export interface GjsifyNativescriptOptions {
40
+ /**
41
+ * Enable Deepkit type reflection. Off by default — matches gjsifyBrowser.
42
+ */
43
+ reflection?: boolean;
44
+ /**
45
+ * Extra `resolve.alias` entries merged on top of `ALIASES_NODE_FOR_NATIVESCRIPT`.
46
+ * User entries win over the defaults.
47
+ */
48
+ aliases?: Record<string, string>;
49
+ /**
50
+ * Extra package names to add to Vite's `optimizeDeps.exclude`. `@gjsify/unit`
51
+ * is always excluded.
52
+ */
53
+ optimizeDepsExclude?: string[];
54
+ }
55
+ /**
56
+ * Returns the Vite plugin array that brings `gjsify build --app nativescript`'s
57
+ * NS-target transforms to a Vite project (dev + build). Spread it into a
58
+ * Vite config's `plugins`:
59
+ *
60
+ * ```ts
61
+ * import { defineConfig } from 'vite';
62
+ * import { gjsifyNativescript } from '@gjsify/vite-plugin-gjsify';
63
+ * import nativescript from '@nativescript/vite';
64
+ *
65
+ * export default defineConfig({
66
+ * plugins: [nativescript(), ...gjsifyNativescript()],
67
+ * });
68
+ * ```
69
+ */
70
+ export declare function gjsifyNativescript(options?: GjsifyNativescriptOptions): Plugin[];
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@
31
31
  import { gjsImportsEmptyPlugin } from '@gjsify/rolldown-plugin-gjsify';
32
32
  import blueprintPlugin from '@gjsify/vite-plugin-blueprint';
33
33
  import { deepkitPlugin } from '@gjsify/rolldown-plugin-deepkit';
34
+ import { ALIASES_NODE_FOR_NATIVESCRIPT } from '@gjsify/resolve-npm';
34
35
  /**
35
36
  * Returns the Vite plugin array that brings `gjsify build --app browser`'s
36
37
  * browser-target transforms to a Vite project (dev + build), minus
@@ -98,3 +99,63 @@ export function gjsifyBrowser(options = {}) {
98
99
  ];
99
100
  }
100
101
  export default gjsifyBrowser;
102
+ /**
103
+ * Returns the Vite plugin array that brings `gjsify build --app nativescript`'s
104
+ * NS-target transforms to a Vite project (dev + build). Spread it into a
105
+ * Vite config's `plugins`:
106
+ *
107
+ * ```ts
108
+ * import { defineConfig } from 'vite';
109
+ * import { gjsifyNativescript } from '@gjsify/vite-plugin-gjsify';
110
+ * import nativescript from '@nativescript/vite';
111
+ *
112
+ * export default defineConfig({
113
+ * plugins: [nativescript(), ...gjsifyNativescript()],
114
+ * });
115
+ * ```
116
+ */
117
+ export function gjsifyNativescript(options = {}) {
118
+ // Bare Node-builtin + node:* prefix aliases. Both forms route to the same
119
+ // `@gjsify/<X>` target. Generated from `ALIASES_NODE_FOR_NATIVESCRIPT` so
120
+ // the single source-of-truth in `@gjsify/resolve-npm` drives every build,
121
+ // matching the Rolldown-side `app/nativescript.ts` composition.
122
+ const nodePrefixAliases = {};
123
+ for (const [bare, target] of Object.entries(ALIASES_NODE_FOR_NATIVESCRIPT)) {
124
+ nodePrefixAliases[bare] = target;
125
+ nodePrefixAliases[`node:${bare}`] = target;
126
+ }
127
+ const alias = {
128
+ ...nodePrefixAliases,
129
+ ...options.aliases,
130
+ };
131
+ const optimizeDepsExclude = ['@gjsify/unit', ...(options.optimizeDepsExclude ?? [])];
132
+ const configPlugin = {
133
+ name: 'gjsify-nativescript-config',
134
+ config() {
135
+ return {
136
+ resolve: {
137
+ alias,
138
+ conditions: ['import', 'nativescript'],
139
+ mainFields: ['nativescript', 'module', 'main'],
140
+ },
141
+ define: {
142
+ global: 'globalThis',
143
+ // NO `window` define — NS apps have no DOM
144
+ },
145
+ build: {
146
+ target: 'esnext',
147
+ },
148
+ optimizeDeps: {
149
+ exclude: optimizeDepsExclude,
150
+ },
151
+ };
152
+ },
153
+ };
154
+ return [
155
+ gjsImportsEmptyPlugin(),
156
+ // NO blueprintPlugin — Blueprint is GTK-specific
157
+ // NO cssAsStringPlugin — NS handles CSS via @nativescript/core
158
+ deepkitPlugin({ reflection: options.reflection }),
159
+ configPlugin,
160
+ ];
161
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gjsify/vite-plugin-gjsify",
3
- "version": "0.4.35",
4
- "description": "Vite plugin preset that mirrors `gjsify build --app browser` — dev (Vite/HMR) parity with the gjsify browser target.",
3
+ "version": "0.4.36",
4
+ "description": "Vite plugin presets mirroring `gjsify build --app browser` / `--app nativescript` — dev (Vite/HMR) parity with the gjsify CLI targets.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "module": "lib/index.js",
@@ -39,12 +39,13 @@
39
39
  ],
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
- "@gjsify/rolldown-plugin-deepkit": "^0.4.35",
43
- "@gjsify/rolldown-plugin-gjsify": "^0.4.35",
44
- "@gjsify/vite-plugin-blueprint": "^0.4.35"
42
+ "@gjsify/resolve-npm": "^0.4.36",
43
+ "@gjsify/rolldown-plugin-deepkit": "^0.4.36",
44
+ "@gjsify/rolldown-plugin-gjsify": "^0.4.36",
45
+ "@gjsify/vite-plugin-blueprint": "^0.4.36"
45
46
  },
46
47
  "peerDependencies": {
47
- "vite": "^8.0.11"
48
+ "vite": "^8.0.14"
48
49
  },
49
50
  "peerDependenciesMeta": {
50
51
  "vite": {
@@ -53,7 +54,7 @@
53
54
  },
54
55
  "devDependencies": {
55
56
  "@types/node": "^25.9.1",
56
- "typescript": "^6.0.3",
57
- "vite": "^8.0.11"
57
+ "typescript": "^5.9.3",
58
+ "vite": "^8.0.14"
58
59
  }
59
60
  }