@gjsify/nativescript-vite 0.13.1 → 0.14.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.
- package/lib/index.d.ts +23 -0
- package/lib/index.js +51 -2
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -31,6 +31,29 @@ export type UserConfigInput = UserConfig | ((env: ConfigEnv) => UserConfig | Pro
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function defineNativescriptConfig(options?: GjsifyNativescriptViteOptions, userConfig?: UserConfigInput): (env: ConfigEnv) => Promise<UserConfig>;
|
|
33
33
|
export default defineNativescriptConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Stabilise the NativeScript build output so the Android Static Binding
|
|
36
|
+
* Generator never sees a native class extended twice.
|
|
37
|
+
*
|
|
38
|
+
* `@nativescript/vite@8` names non-vendor / non-worker chunks `[name]-[hash].mjs`
|
|
39
|
+
* and leaves `build.emptyOutDir` unset. The NS CLI then copies the staging dir
|
|
40
|
+
* (`.ns-vite-build`) into `platforms/android/app/src/main/assets/app/`
|
|
41
|
+
* ADDITIVELY — it never deletes stale files. So every build whose content
|
|
42
|
+
* changes emits a fresh `activity.android-<hash>.mjs`, and `assets/app` ends up
|
|
43
|
+
* holding TWO of them: the SBG scans both, sees `NativeScriptActivity`'s
|
|
44
|
+
* `extends` declaration twice and aborts with "File already exists … change the
|
|
45
|
+
* name of one of the extended classes". The documented workaround was a manual
|
|
46
|
+
* `rm -rf .ns-vite-build` + `assets/app/*.mjs` before every build.
|
|
47
|
+
*
|
|
48
|
+
* The entry (`bundle.mjs`) and vendor chunk (`vendor.mjs`) are ALREADY stable
|
|
49
|
+
* upstream; this extends that to every chunk (so a rebuild OVERWRITES rather
|
|
50
|
+
* than accumulates) and empties the staging dir each build. Merged over the
|
|
51
|
+
* upstream config but under the user's, so an app can still override it.
|
|
52
|
+
*
|
|
53
|
+
* NOTE: a one-time clean of a pre-existing `assets/app/*.mjs` is still needed to
|
|
54
|
+
* drop chunks that already accumulated; from then on the names stay stable.
|
|
55
|
+
*/
|
|
56
|
+
export declare function nativescriptSbgBundleSyncFix(): UserConfig;
|
|
34
57
|
/**
|
|
35
58
|
* Pure core of {@link repointMistargetedCoreAlias} (exported for testing, since
|
|
36
59
|
* the wrapper resolves the real `@nativescript/core` from disk).
|
package/lib/index.js
CHANGED
|
@@ -92,13 +92,62 @@ export function defineNativescriptConfig(options = {}, userConfig) {
|
|
|
92
92
|
const withTransforms = mergeConfig(fixed, {
|
|
93
93
|
plugins: [...gjsifyNativescriptTransforms(options)],
|
|
94
94
|
});
|
|
95
|
+
// Stabilise the build output so repeated `ns prepare`/`ns build` runs do
|
|
96
|
+
// not accumulate stale, hashed chunk files the Android SBG then sees as a
|
|
97
|
+
// duplicate native `extends` (see {@link nativescriptSbgBundleSyncFix}).
|
|
98
|
+
const withSbgFix = mergeConfig(withTransforms, nativescriptSbgBundleSyncFix());
|
|
95
99
|
if (userConfig === undefined)
|
|
96
|
-
return
|
|
100
|
+
return withSbgFix;
|
|
97
101
|
const resolved = typeof userConfig === 'function' ? await userConfig(env) : userConfig;
|
|
98
|
-
return mergeConfig(
|
|
102
|
+
return mergeConfig(withSbgFix, resolved);
|
|
99
103
|
};
|
|
100
104
|
}
|
|
101
105
|
export default defineNativescriptConfig;
|
|
106
|
+
/**
|
|
107
|
+
* Stabilise the NativeScript build output so the Android Static Binding
|
|
108
|
+
* Generator never sees a native class extended twice.
|
|
109
|
+
*
|
|
110
|
+
* `@nativescript/vite@8` names non-vendor / non-worker chunks `[name]-[hash].mjs`
|
|
111
|
+
* and leaves `build.emptyOutDir` unset. The NS CLI then copies the staging dir
|
|
112
|
+
* (`.ns-vite-build`) into `platforms/android/app/src/main/assets/app/`
|
|
113
|
+
* ADDITIVELY — it never deletes stale files. So every build whose content
|
|
114
|
+
* changes emits a fresh `activity.android-<hash>.mjs`, and `assets/app` ends up
|
|
115
|
+
* holding TWO of them: the SBG scans both, sees `NativeScriptActivity`'s
|
|
116
|
+
* `extends` declaration twice and aborts with "File already exists … change the
|
|
117
|
+
* name of one of the extended classes". The documented workaround was a manual
|
|
118
|
+
* `rm -rf .ns-vite-build` + `assets/app/*.mjs` before every build.
|
|
119
|
+
*
|
|
120
|
+
* The entry (`bundle.mjs`) and vendor chunk (`vendor.mjs`) are ALREADY stable
|
|
121
|
+
* upstream; this extends that to every chunk (so a rebuild OVERWRITES rather
|
|
122
|
+
* than accumulates) and empties the staging dir each build. Merged over the
|
|
123
|
+
* upstream config but under the user's, so an app can still override it.
|
|
124
|
+
*
|
|
125
|
+
* NOTE: a one-time clean of a pre-existing `assets/app/*.mjs` is still needed to
|
|
126
|
+
* drop chunks that already accumulated; from then on the names stay stable.
|
|
127
|
+
*/
|
|
128
|
+
export function nativescriptSbgBundleSyncFix() {
|
|
129
|
+
return {
|
|
130
|
+
build: {
|
|
131
|
+
// Clear the staging dir each (non-watch) build so stale chunks don't linger.
|
|
132
|
+
emptyOutDir: true,
|
|
133
|
+
rolldownOptions: {
|
|
134
|
+
output: {
|
|
135
|
+
// Drop the content hash from chunk names — matching the
|
|
136
|
+
// already-stable `bundle.mjs` entry + `vendor.mjs` — so a
|
|
137
|
+
// rebuild overwrites the same files instead of piling up
|
|
138
|
+
// `activity.android-<hash>.mjs` copies for the SBG to trip on.
|
|
139
|
+
chunkFileNames: (chunk) => {
|
|
140
|
+
if (chunk.name === 'vendor')
|
|
141
|
+
return 'vendor.mjs';
|
|
142
|
+
if (chunk.name && chunk.name.includes('worker'))
|
|
143
|
+
return '[name].js';
|
|
144
|
+
return '[name].mjs';
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
102
151
|
/**
|
|
103
152
|
* Repoint a mis-targeted `@nativescript/core` resolve.alias.
|
|
104
153
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/nativescript-vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@gjsify/vite-plugin-gjsify": "^0.
|
|
41
|
+
"@gjsify/vite-plugin-gjsify": "^0.14.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@nativescript/canvas": "*",
|