@gjsify/vite-plugin-gjsify 0.56.0 → 0.58.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.js CHANGED
@@ -42,6 +42,7 @@ import { gjsImportsEmptyPlugin, platformResolvePlugin, nativescriptSuffixChain,
42
42
  import blueprintPlugin from '@gjsify/vite-plugin-blueprint';
43
43
  import { deepkitPlugin } from '@gjsify/rolldown-plugin-deepkit';
44
44
  import { ALIASES_NODE_FOR_NATIVESCRIPT } from '@gjsify/resolve-npm';
45
+ import { installedGjsifyPackages } from './nativescript-dedupe.js';
45
46
  /**
46
47
  * Returns the Vite plugin array that brings `gjsify build --app browser`'s
47
48
  * browser-target transforms to a Vite project (dev + build), minus
@@ -332,6 +333,7 @@ export function gjsifyNativescript(options = {}) {
332
333
  alias: { ...nodePrefixAliases, ...nativescriptCssTreeAlias(root), ...options.aliases },
333
334
  conditions: ['import', 'nativescript'],
334
335
  mainFields: ['nativescript', 'module', 'main'],
336
+ dedupe: installedGjsifyPackages(root),
335
337
  },
336
338
  define: {
337
339
  global: 'globalThis',
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Names of the `@gjsify/*` packages installed in `<root>/node_modules` or in any
3
+ * ancestor's, for `resolve.dedupe`.
4
+ *
5
+ * `gjsify install` links every workspace dep into the requester's own
6
+ * `node_modules/` (`<pkg>/node_modules/@gjsify/<dep>`). Under `gjsify link`
7
+ * the consumer reaches such a package through its symlink, and
8
+ * `@nativescript/vite` sets `resolve.preserveSymlinks: true`, so the nested link
9
+ * keeps its own path spelling: one package becomes TWO modules in the bundle
10
+ * (`@gjsify/adwaita-core` twice, then "'gtk:Box' resolves to class GtkBox$1").
11
+ * Deduping resolves every `@gjsify/*` import through the consumer instead, so
12
+ * its copy is the only one.
13
+ *
14
+ * Walks UP, merging every level: in a workspace the app dir usually has no
15
+ * `node_modules` of its own because deps are hoisted to the workspace root, and
16
+ * a partly populated nearer level must not hide the root's packages.
17
+ */
18
+ export declare function installedGjsifyPackages(root: string): string[];
@@ -0,0 +1,37 @@
1
+ import { existsSync, readdirSync } from 'node:fs';
2
+ import { dirname, join, resolve } from 'node:path';
3
+ /**
4
+ * Names of the `@gjsify/*` packages installed in `<root>/node_modules` or in any
5
+ * ancestor's, for `resolve.dedupe`.
6
+ *
7
+ * `gjsify install` links every workspace dep into the requester's own
8
+ * `node_modules/` (`<pkg>/node_modules/@gjsify/<dep>`). Under `gjsify link`
9
+ * the consumer reaches such a package through its symlink, and
10
+ * `@nativescript/vite` sets `resolve.preserveSymlinks: true`, so the nested link
11
+ * keeps its own path spelling: one package becomes TWO modules in the bundle
12
+ * (`@gjsify/adwaita-core` twice, then "'gtk:Box' resolves to class GtkBox$1").
13
+ * Deduping resolves every `@gjsify/*` import through the consumer instead, so
14
+ * its copy is the only one.
15
+ *
16
+ * Walks UP, merging every level: in a workspace the app dir usually has no
17
+ * `node_modules` of its own because deps are hoisted to the workspace root, and
18
+ * a partly populated nearer level must not hide the root's packages.
19
+ */
20
+ export function installedGjsifyPackages(root) {
21
+ const names = new Set();
22
+ let dir = resolve(root);
23
+ while (true) {
24
+ const scope = join(dir, 'node_modules', '@gjsify');
25
+ if (existsSync(scope)) {
26
+ for (const name of readdirSync(scope)) {
27
+ if (!name.startsWith('.'))
28
+ names.add(`@gjsify/${name}`);
29
+ }
30
+ }
31
+ const parent = dirname(dir);
32
+ if (parent === dir)
33
+ break;
34
+ dir = parent;
35
+ }
36
+ return [...names].sort();
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/vite-plugin-gjsify",
3
- "version": "0.56.0",
3
+ "version": "0.58.0",
4
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",
@@ -16,9 +16,12 @@
16
16
  "lib"
17
17
  ],
18
18
  "scripts": {
19
- "clear": "gjsify clear lib tsconfig.tsbuildinfo",
19
+ "clear": "gjsify clear lib tsconfig.tsbuildinfo test.node.mjs",
20
20
  "check": "gjsify tsc --noEmit",
21
- "build": "gjsify tsc"
21
+ "build": "gjsify tsc -p tsconfig.build.json",
22
+ "build:test": "gjsify build src/test.mts --app node --outfile test.node.mjs",
23
+ "test": "gjsify run build:test && gjsify run test:node",
24
+ "test:node": "node test.node.mjs"
22
25
  },
23
26
  "repository": {
24
27
  "type": "git",
@@ -40,11 +43,11 @@
40
43
  ],
41
44
  "license": "MIT",
42
45
  "dependencies": {
43
- "@gjsify/empty": "^0.56.0",
44
- "@gjsify/resolve-npm": "^0.56.0",
45
- "@gjsify/rolldown-plugin-deepkit": "^0.56.0",
46
- "@gjsify/rolldown-plugin-gjsify": "^0.56.0",
47
- "@gjsify/vite-plugin-blueprint": "^0.56.0"
46
+ "@gjsify/empty": "^0.58.0",
47
+ "@gjsify/resolve-npm": "^0.58.0",
48
+ "@gjsify/rolldown-plugin-deepkit": "^0.58.0",
49
+ "@gjsify/rolldown-plugin-gjsify": "^0.58.0",
50
+ "@gjsify/vite-plugin-blueprint": "^0.58.0"
48
51
  },
49
52
  "peerDependencies": {
50
53
  "vite": "^8.1.3"
@@ -55,6 +58,8 @@
55
58
  }
56
59
  },
57
60
  "devDependencies": {
61
+ "@gjsify/cli": "^0.58.0",
62
+ "@gjsify/unit": "^0.58.0",
58
63
  "@types/node": "^25.9.2",
59
64
  "typescript": "^6.0.3",
60
65
  "vite": "^8.1.3"