@gjsify/nativescript-vite 0.64.16 → 0.64.17
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 +17 -1
- package/lib/index.js +58 -3
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfigEnv, UserConfig, Alias } from 'vite';
|
|
1
|
+
import type { ConfigEnv, UserConfig, Plugin, Alias } from 'vite';
|
|
2
2
|
import type { GjsifyNativescriptOptions } from '@gjsify/vite-plugin-gjsify';
|
|
3
3
|
export { nativescriptCssNesting } from './css-nesting.js';
|
|
4
4
|
export type GjsifyNativescriptViteOptions = GjsifyNativescriptOptions;
|
|
@@ -70,6 +70,22 @@ export declare function nativescriptSbgBundleSyncFix(): UserConfig;
|
|
|
70
70
|
* Merged under the user's config: an app that wants the split back sets its own `manualChunks`.
|
|
71
71
|
*/
|
|
72
72
|
export declare function nativescriptSingleChunk(): UserConfig;
|
|
73
|
+
/**
|
|
74
|
+
* One module instance per file, however many symlink paths lead to it.
|
|
75
|
+
*
|
|
76
|
+
* `@nativescript/vite` sets `resolve.preserveSymlinks: true` (upstream gives no reason; the
|
|
77
|
+
* visible cases are `file:`-linked `@nativescript/core` dists and aliases that compare
|
|
78
|
+
* unresolved paths, so flipping it off would change what the upstream aliases match). In a
|
|
79
|
+
* workspace monorepo that makes every symlink path its own module id: a package reachable as
|
|
80
|
+
* `packages/a/node_modules/@scope/x` AND `packages/b/node_modules/@scope/x` is bundled twice, and
|
|
81
|
+
* its module-level state (an engine registry, a singleton) splits — `useRealGObjectEngine()`
|
|
82
|
+
* registers in one copy while `@gjsify/adwaita-nativescript` reads the empty slot of another and
|
|
83
|
+
* dies at launch with "No GObject engine was registered".
|
|
84
|
+
*
|
|
85
|
+
* So resolve as upstream does, then pin each REAL file to the first id it was reached by. This
|
|
86
|
+
* covers every package (no list to rot) and leaves upstream's symlink-path resolution intact.
|
|
87
|
+
*/
|
|
88
|
+
export declare function nativescriptDedupeSymlinks(): Plugin;
|
|
73
89
|
/**
|
|
74
90
|
* Minifier defaults under which a RELEASE build of a NativeScript app still launches.
|
|
75
91
|
*
|
package/lib/index.js
CHANGED
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
// `@nativescript/vite`, `@nativescript/core`, the `nativescript` CLI, the
|
|
46
46
|
// optional `@nativescript/canvas*` plugins and `vite` are all OPTIONAL peer
|
|
47
47
|
// dependencies — installed by the consumer only when targeting NativeScript.
|
|
48
|
-
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
48
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
49
49
|
import module, { createRequire } from 'node:module';
|
|
50
|
-
import { dirname, join } from 'node:path';
|
|
50
|
+
import { dirname, isAbsolute, join } from 'node:path';
|
|
51
51
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
52
52
|
import { mergeConfig } from 'vite';
|
|
53
53
|
import { gjsifyNativescript as gjsifyNativescriptTransforms } from '@gjsify/vite-plugin-gjsify';
|
|
@@ -92,7 +92,7 @@ export function defineNativescriptConfig(options = {}, userConfig) {
|
|
|
92
92
|
// node-builtin aliases) — the same composition proven to produce a
|
|
93
93
|
// working Vite 8 bundle.
|
|
94
94
|
const withTransforms = mergeConfig(fixed, {
|
|
95
|
-
plugins: [...gjsifyNativescriptTransforms(options)],
|
|
95
|
+
plugins: [...gjsifyNativescriptTransforms(options), nativescriptDedupeSymlinks()],
|
|
96
96
|
});
|
|
97
97
|
// Stabilise the build output so repeated `ns prepare`/`ns build` runs do
|
|
98
98
|
// not accumulate stale, hashed chunk files the Android SBG then sees as a
|
|
@@ -183,6 +183,61 @@ export function nativescriptSingleChunk() {
|
|
|
183
183
|
},
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* One module instance per file, however many symlink paths lead to it.
|
|
188
|
+
*
|
|
189
|
+
* `@nativescript/vite` sets `resolve.preserveSymlinks: true` (upstream gives no reason; the
|
|
190
|
+
* visible cases are `file:`-linked `@nativescript/core` dists and aliases that compare
|
|
191
|
+
* unresolved paths, so flipping it off would change what the upstream aliases match). In a
|
|
192
|
+
* workspace monorepo that makes every symlink path its own module id: a package reachable as
|
|
193
|
+
* `packages/a/node_modules/@scope/x` AND `packages/b/node_modules/@scope/x` is bundled twice, and
|
|
194
|
+
* its module-level state (an engine registry, a singleton) splits — `useRealGObjectEngine()`
|
|
195
|
+
* registers in one copy while `@gjsify/adwaita-nativescript` reads the empty slot of another and
|
|
196
|
+
* dies at launch with "No GObject engine was registered".
|
|
197
|
+
*
|
|
198
|
+
* So resolve as upstream does, then pin each REAL file to the first id it was reached by. This
|
|
199
|
+
* covers every package (no list to rot) and leaves upstream's symlink-path resolution intact.
|
|
200
|
+
*/
|
|
201
|
+
export function nativescriptDedupeSymlinks() {
|
|
202
|
+
const realToId = new Map();
|
|
203
|
+
const realOf = new Map();
|
|
204
|
+
const realpath = (file) => {
|
|
205
|
+
let real = realOf.get(file);
|
|
206
|
+
if (real === undefined) {
|
|
207
|
+
try {
|
|
208
|
+
real = realpathSync(file);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
real = file;
|
|
212
|
+
}
|
|
213
|
+
realOf.set(file, real);
|
|
214
|
+
}
|
|
215
|
+
return real;
|
|
216
|
+
};
|
|
217
|
+
return {
|
|
218
|
+
name: 'gjsify:nativescript-dedupe-symlinks',
|
|
219
|
+
enforce: 'pre',
|
|
220
|
+
async resolveId(source, importer, options) {
|
|
221
|
+
if (source.startsWith('\0') || options.isEntry)
|
|
222
|
+
return null;
|
|
223
|
+
const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });
|
|
224
|
+
if (!resolved || resolved.external || resolved.id.startsWith('\0') || !isAbsolute(resolved.id)) {
|
|
225
|
+
return resolved;
|
|
226
|
+
}
|
|
227
|
+
const query = resolved.id.search(/[?#]/);
|
|
228
|
+
const file = query === -1 ? resolved.id : resolved.id.slice(0, query);
|
|
229
|
+
const real = realpath(file);
|
|
230
|
+
const first = realToId.get(real);
|
|
231
|
+
if (first === undefined) {
|
|
232
|
+
realToId.set(real, file);
|
|
233
|
+
return resolved;
|
|
234
|
+
}
|
|
235
|
+
if (first === file)
|
|
236
|
+
return resolved;
|
|
237
|
+
return { ...resolved, id: query === -1 ? first : first + resolved.id.slice(query) };
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
186
241
|
/**
|
|
187
242
|
* Minifier defaults under which a RELEASE build of a NativeScript app still launches.
|
|
188
243
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/nativescript-vite",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.17",
|
|
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,8 +39,8 @@
|
|
|
39
39
|
],
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@gjsify/adwaita-core": "^0.64.
|
|
43
|
-
"@gjsify/vite-plugin-gjsify": "^0.64.
|
|
42
|
+
"@gjsify/adwaita-core": "^0.64.17",
|
|
43
|
+
"@gjsify/vite-plugin-gjsify": "^0.64.17",
|
|
44
44
|
"postcss-nesting": "^13.0.2",
|
|
45
45
|
"postcss-selector-parser": "^7.1.0"
|
|
46
46
|
},
|