@gjsify/nativescript-vite 0.64.2-next.252 → 0.64.2-next.253
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/README.md +1 -1
- package/lib/index.d.ts +15 -0
- package/lib/index.js +61 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ It is a **thin composer** around the upstream `@nativescript/vite` integration.
|
|
|
15
15
|
1. **Function-replacement `resolve.alias` entries are dropped.** `@nativescript/vite` registers aliases whose `replacement` is a *function* (platform-`main`, the tsconfig wildcard, `@nativescript/core/.../index` canonicalization). Vite 8's native alias (Rolldown) only accepts string replacements and otherwise fails with `Failed to convert builtin plugin 'ViteAlias' … function replacement into rust type String`. The upstream `nativescript-package-resolver` plugin (a `resolveId` hook, kept) and the string `~/` / `@` aliases (kept) already cover the same resolution, so dropping the function entries is safe.
|
|
16
16
|
2. **The explicit `@rollup/plugin-commonjs` plugin is removed.** It crashes Rolldown with `Cannot read properties of undefined (reading 'currentLoadingModule')`. Rolldown handles CommonJS (`@nativescript/core`'s modules) natively, so the plugin is not needed.
|
|
17
17
|
|
|
18
|
-
On top of the fixes, it spreads `@gjsify/vite-plugin-gjsify`'s `gjsifyNativescript()` preset: `gi://` → empty module, platform file resolution (`*.android` / `*.ios` / `*.native`), platform defines (`__ANDROID__` / `__IOS__` / `__APPLE__` / `__VISIONOS__` / `__DEV__`), and the node-builtin alias routing (incl. `module` → `@gjsify/module`).
|
|
18
|
+
On top of the fixes, it spreads `@gjsify/vite-plugin-gjsify`'s `gjsifyNativescript()` preset: `gi://` → empty module, `*.gresource.xml` imports embedded as bytes (ADR 0116), platform file resolution (`*.android` / `*.ios` / `*.native`), platform defines (`__ANDROID__` / `__IOS__` / `__APPLE__` / `__VISIONOS__` / `__DEV__`), and the node-builtin alias routing (incl. `module` → `@gjsify/module`).
|
|
19
19
|
|
|
20
20
|
## Release-build minifier defaults
|
|
21
21
|
|
package/lib/index.d.ts
CHANGED
|
@@ -54,6 +54,21 @@ export default defineNativescriptConfig;
|
|
|
54
54
|
* drop chunks that already accumulated; from then on the names stay stable.
|
|
55
55
|
*/
|
|
56
56
|
export declare function nativescriptSbgBundleSyncFix(): UserConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Keep the whole app in the entry chunk, so plain ESM evaluation order decides what runs first.
|
|
59
|
+
*
|
|
60
|
+
* `@nativescript/vite` moves every `node_modules` module except `@nativescript/core` into
|
|
61
|
+
* `vendor.mjs`, which `bundle.mjs` imports as its first statement — so ALL of vendor evaluates
|
|
62
|
+
* before ANY app module. Since ADR 0110 an Android app MUST pick its GObject engine
|
|
63
|
+
* (`useRealGObjectEngine` / `usePureJsGObjectEngine`) in its own module before
|
|
64
|
+
* `@gjsify/adwaita-nativescript` loads; with the split, the port (vendor) reads the empty slot
|
|
65
|
+
* before the app's opt-in (bundle) can run, and the app dies at launch with "No GObject engine was
|
|
66
|
+
* registered". No import order inside the app can fix that, so the default must. Measured in
|
|
67
|
+
* `tests/integration/nativescript-gi` on 2026-10-11 and in Learn6502 on 2026-10-17.
|
|
68
|
+
*
|
|
69
|
+
* Merged under the user's config: an app that wants the split back sets its own `manualChunks`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function nativescriptSingleChunk(): UserConfig;
|
|
57
72
|
/**
|
|
58
73
|
* Minifier defaults under which a RELEASE build of a NativeScript app still launches.
|
|
59
74
|
*
|
package/lib/index.js
CHANGED
|
@@ -95,7 +95,7 @@ export function defineNativescriptConfig(options = {}, userConfig) {
|
|
|
95
95
|
// Stabilise the build output so repeated `ns prepare`/`ns build` runs do
|
|
96
96
|
// not accumulate stale, hashed chunk files the Android SBG then sees as a
|
|
97
97
|
// duplicate native `extends` (see {@link nativescriptSbgBundleSyncFix}).
|
|
98
|
-
const withSbgFix = mergeConfig(withTransforms, nativescriptSbgBundleSyncFix());
|
|
98
|
+
const withSbgFix = mergeConfig(mergeConfig(withTransforms, nativescriptSbgBundleSyncFix()), nativescriptSingleChunk());
|
|
99
99
|
// Keep the strings and decorators NativeScript's static binding generator reads
|
|
100
100
|
// (see {@link nativescriptReleaseMinify}); a consumer's own `build.minify` wins below.
|
|
101
101
|
const withMinify = mergeConfig(withSbgFix, nativescriptReleaseMinify(withSbgFix));
|
|
@@ -151,6 +151,31 @@ export function nativescriptSbgBundleSyncFix() {
|
|
|
151
151
|
},
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Keep the whole app in the entry chunk, so plain ESM evaluation order decides what runs first.
|
|
156
|
+
*
|
|
157
|
+
* `@nativescript/vite` moves every `node_modules` module except `@nativescript/core` into
|
|
158
|
+
* `vendor.mjs`, which `bundle.mjs` imports as its first statement — so ALL of vendor evaluates
|
|
159
|
+
* before ANY app module. Since ADR 0110 an Android app MUST pick its GObject engine
|
|
160
|
+
* (`useRealGObjectEngine` / `usePureJsGObjectEngine`) in its own module before
|
|
161
|
+
* `@gjsify/adwaita-nativescript` loads; with the split, the port (vendor) reads the empty slot
|
|
162
|
+
* before the app's opt-in (bundle) can run, and the app dies at launch with "No GObject engine was
|
|
163
|
+
* registered". No import order inside the app can fix that, so the default must. Measured in
|
|
164
|
+
* `tests/integration/nativescript-gi` on 2026-10-11 and in Learn6502 on 2026-10-17.
|
|
165
|
+
*
|
|
166
|
+
* Merged under the user's config: an app that wants the split back sets its own `manualChunks`.
|
|
167
|
+
*/
|
|
168
|
+
export function nativescriptSingleChunk() {
|
|
169
|
+
return {
|
|
170
|
+
build: {
|
|
171
|
+
rolldownOptions: {
|
|
172
|
+
output: {
|
|
173
|
+
manualChunks: () => undefined,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
154
179
|
/**
|
|
155
180
|
* Minifier defaults under which a RELEASE build of a NativeScript app still launches.
|
|
156
181
|
*
|
|
@@ -502,6 +527,9 @@ function stubMissingFrameworkPeers() {
|
|
|
502
527
|
}
|
|
503
528
|
/** Upstream `@nativescript/vite` TypeScript-check plugin name (see `helpers/typescript-check.js`). */
|
|
504
529
|
const TS_CHECK_PLUGIN = 'ns-typescript-check';
|
|
530
|
+
/** `@nativescript/vite`'s `createXmlLoaderPlugin` names (TS and JS configurations). */
|
|
531
|
+
const XML_LOADER_PLUGINS = new Set(['ns-xml-loader-ts', 'ns-xml-loader-js']);
|
|
532
|
+
const GRESOURCE_SUFFIX = /\.gresource\.xml$/i;
|
|
505
533
|
/** First `@nativescript/vite` major that ships native Vite-8 / Rolldown support. */
|
|
506
534
|
const NS_VITE_NATIVE_VITE8_MAJOR = 8;
|
|
507
535
|
/** One-time guard so the "8.x handles Vite-8 natively" notice prints at most once per process. */
|
|
@@ -680,8 +708,40 @@ export function applyVite8Fixes(config, nsViteMajor) {
|
|
|
680
708
|
"app's own tsc accepts). Run `gjsify tsc` for the authoritative type gate.");
|
|
681
709
|
}
|
|
682
710
|
}
|
|
711
|
+
// Fix (4): `@nativescript/vite`'s `enforce: 'pre'` XML loader claims EVERY `.xml` as a string
|
|
712
|
+
// (`const ___XML___ = …`), so a `.gresource.xml` import never reached `gresourcePlugin` and
|
|
713
|
+
// `Gio.Resource.new_from_data` got the descriptor's source instead of its bytes (ADR 0116
|
|
714
|
+
// § 1). Its views stay plain `.xml`; only the gresource suffix is handed on. On EITHER line.
|
|
715
|
+
if (Array.isArray(out.plugins))
|
|
716
|
+
out.plugins = skipGresourceInXmlLoaders(out.plugins);
|
|
683
717
|
return out;
|
|
684
718
|
}
|
|
719
|
+
/**
|
|
720
|
+
* Wrap every upstream XML loader so its `load` returns `null` for `*.gresource.xml`, preserving
|
|
721
|
+
* order and nesting. A non-function `load` (an object hook) is left as it is.
|
|
722
|
+
*/
|
|
723
|
+
function skipGresourceInXmlLoaders(plugins) {
|
|
724
|
+
if (!Array.isArray(plugins))
|
|
725
|
+
return plugins;
|
|
726
|
+
return plugins.map((entry) => {
|
|
727
|
+
if (Array.isArray(entry))
|
|
728
|
+
return skipGresourceInXmlLoaders(entry);
|
|
729
|
+
const plugin = entry;
|
|
730
|
+
if (!plugin || typeof plugin !== 'object' || !XML_LOADER_PLUGINS.has(plugin.name))
|
|
731
|
+
return entry;
|
|
732
|
+
const load = plugin.load;
|
|
733
|
+
if (typeof load !== 'function')
|
|
734
|
+
return entry;
|
|
735
|
+
return {
|
|
736
|
+
...plugin,
|
|
737
|
+
load(id, ...rest) {
|
|
738
|
+
if (GRESOURCE_SUFFIX.test(id.split('?')[0] ?? id))
|
|
739
|
+
return null;
|
|
740
|
+
return load.call(this, id, ...rest);
|
|
741
|
+
},
|
|
742
|
+
};
|
|
743
|
+
});
|
|
744
|
+
}
|
|
685
745
|
/**
|
|
686
746
|
* Keep only `resolve.alias` entries Vite 8 / Rolldown accepts. The array form
|
|
687
747
|
* may carry function `replacement`s (Vite types `Alias.replacement` as `string`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/nativescript-vite",
|
|
3
|
-
"version": "0.64.2-next.
|
|
3
|
+
"version": "0.64.2-next.253",
|
|
4
4
|
"description": "Vite 8 / Rolldown compatibility + gjsify transforms for building NativeScript apps — composes @nativescript/vite and fixes the pieces Rolldown rejects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@gjsify/vite-plugin-gjsify": "0.64.2-next.
|
|
42
|
+
"@gjsify/vite-plugin-gjsify": "0.64.2-next.253"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@nativescript/canvas": "*",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"gjsify": {
|
|
82
82
|
"tier": 2
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "84c860498d8dd191285353b116e60aa90d71776c"
|
|
85
85
|
}
|