@gjsify/rolldown-plugin-gjsify 0.52.0 → 0.54.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.
Files changed (43) hide show
  1. package/README.md +11 -0
  2. package/lib/app/browser.js +1 -0
  3. package/lib/app/gjs.js +18 -2
  4. package/lib/app/nativescript.js +1 -1
  5. package/lib/app/node.d.ts +1 -1
  6. package/lib/app/node.js +34 -10
  7. package/lib/index.d.ts +5 -1
  8. package/lib/index.js +4 -1
  9. package/lib/plugins/console-assign.d.ts +13 -0
  10. package/lib/plugins/console-assign.js +125 -0
  11. package/lib/plugins/css-as-string.js +128 -44
  12. package/lib/plugins/gi-optional.d.ts +60 -0
  13. package/lib/plugins/gi-optional.js +152 -0
  14. package/lib/plugins/gi-renderer.d.ts +1 -1
  15. package/lib/plugins/gi-renderer.js +1 -1
  16. package/lib/plugins/gi-runtime-paths.js +5 -2
  17. package/lib/plugins/napi-node-addon.d.ts +48 -4
  18. package/lib/plugins/napi-node-addon.js +261 -85
  19. package/lib/plugins/node-native-external.d.ts +20 -0
  20. package/lib/plugins/node-native-external.js +145 -0
  21. package/lib/plugins/rewrite-node-modules-paths.d.ts +18 -1
  22. package/lib/plugins/rewrite-node-modules-paths.js +181 -25
  23. package/lib/plugins/unresolved-workspace-import.js +89 -68
  24. package/lib/shims/addon-resolve.d.ts +19 -0
  25. package/lib/shims/addon-resolve.js +193 -0
  26. package/lib/utils/addon-platform.d.ts +23 -0
  27. package/lib/utils/addon-platform.js +50 -0
  28. package/lib/utils/auto-globals.d.ts +6 -0
  29. package/lib/utils/auto-globals.js +13 -10
  30. package/lib/utils/declare-build-input.d.ts +13 -0
  31. package/lib/utils/declare-build-input.js +37 -0
  32. package/lib/utils/detect-free-globals.d.ts +3 -0
  33. package/lib/utils/detect-free-globals.js +1 -1
  34. package/lib/utils/entry-wrapper.js +6 -1
  35. package/lib/utils/index.d.ts +1 -0
  36. package/lib/utils/index.js +1 -0
  37. package/lib/utils/inline-static-reads.d.ts +15 -1
  38. package/lib/utils/inline-static-reads.js +16 -8
  39. package/lib/utils/scan-globals.d.ts +2 -2
  40. package/lib/utils/scan-globals.js +20 -14
  41. package/lib/utils/zip-path.d.ts +9 -0
  42. package/lib/utils/zip-path.js +12 -0
  43. package/package.json +13 -9
@@ -126,20 +126,26 @@ export function isRegisterPathResolvable(registerPath, fromDir) {
126
126
  const canonical = resolveRegisterAlias(registerPath);
127
127
  const pkgName = packageNameFromRegisterPath(canonical);
128
128
  const parts = pkgName.split('/');
129
- // Walk up the directory tree mirroring Node's module-resolution
130
- // algorithm: check <dir>/node_modules/<pkg>/package.json at each level.
131
- let dir = fromDir;
132
- const root = dir.slice(0, dir.indexOf('/') + 1) || '/';
133
- while (true) {
134
- const candidate = join(dir, 'node_modules', ...parts, 'package.json');
135
- if (existsSync(candidate))
136
- return true;
137
- if (dir === root)
138
- break;
139
- const parent = join(dir, '..');
140
- if (parent === dir)
141
- break;
142
- dir = parent;
129
+ // Several roots when the build may take a `@gjsify/*` from beside the running CLI
130
+ // (`toolchainAnchor`): the resolver would rescue the import, so this gate must not
131
+ // drop it first — it did, and `gjsify exec` rebuilt a consumer's bin with every
132
+ // global skipped because the PROJECT installs no `@gjsify/*` at all.
133
+ for (const start of typeof fromDir === 'string' ? [fromDir] : fromDir) {
134
+ // Walk up the directory tree mirroring Node's module-resolution
135
+ // algorithm: check <dir>/node_modules/<pkg>/package.json at each level.
136
+ let dir = start;
137
+ const root = dir.slice(0, dir.indexOf('/') + 1) || '/';
138
+ while (true) {
139
+ const candidate = join(dir, 'node_modules', ...parts, 'package.json');
140
+ if (existsSync(candidate))
141
+ return true;
142
+ if (dir === root)
143
+ break;
144
+ const parent = join(dir, '..');
145
+ if (parent === dir)
146
+ break;
147
+ dir = parent;
148
+ }
143
149
  }
144
150
  return false;
145
151
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Does `path` run THROUGH a `.zip` archive (Yarn PnP's `.yarn/cache/<pkg>.zip/...`)?
3
+ *
4
+ * The separator is the host's as well as `/`: `relative()` and rolldown's module ids answer
5
+ * with `\` on win32, where a `.zip/`-only test never matched and a zip-resident module was
6
+ * sent down the on-disk path. `\` counts only there, because on POSIX it is a filename
7
+ * character. `separator` defaults to the host's; a parameter so both hosts are testable on one.
8
+ */
9
+ export declare function hasZipSegment(path: string, separator?: string): boolean;
@@ -0,0 +1,12 @@
1
+ import { sep } from 'node:path';
2
+ /**
3
+ * Does `path` run THROUGH a `.zip` archive (Yarn PnP's `.yarn/cache/<pkg>.zip/...`)?
4
+ *
5
+ * The separator is the host's as well as `/`: `relative()` and rolldown's module ids answer
6
+ * with `\` on win32, where a `.zip/`-only test never matched and a zip-resident module was
7
+ * sent down the on-disk path. `\` counts only there, because on POSIX it is a filename
8
+ * character. `separator` defaults to the host's; a parameter so both hosts are testable on one.
9
+ */
10
+ export function hasZipSegment(path, separator = sep) {
11
+ return path.includes('.zip/') || (separator === '\\' && path.includes('.zip\\'));
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.52.0",
3
+ "version": "0.54.0",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -25,6 +25,9 @@
25
25
  "./shims/module-resolve": {
26
26
  "default": "./lib/shims/module-resolve.js"
27
27
  },
28
+ "./shims/addon-resolve": {
29
+ "default": "./lib/shims/addon-resolve.js"
30
+ },
28
31
  "./shims/unicorn-magic": {
29
32
  "default": "./lib/shims/unicorn-magic.js"
30
33
  }
@@ -60,11 +63,12 @@
60
63
  ],
61
64
  "license": "MIT",
62
65
  "dependencies": {
63
- "@gjsify/console": "^0.52.0",
64
- "@gjsify/resolve-npm": "^0.52.0",
65
- "@gjsify/rolldown-plugin-deepkit": "^0.52.0",
66
- "@gjsify/rolldown-plugin-pnp": "^0.52.0",
67
- "@gjsify/vite-plugin-blueprint": "^0.52.0",
66
+ "@gjsify/console": "^0.54.0",
67
+ "@gjsify/resolve-npm": "^0.54.0",
68
+ "@gjsify/rolldown-plugin-deepkit": "^0.54.0",
69
+ "@gjsify/rolldown-plugin-pnp": "^0.54.0",
70
+ "@gjsify/utils": "^0.54.0",
71
+ "@gjsify/vite-plugin-blueprint": "^0.54.0",
68
72
  "@rollup/pluginutils": "^5.4.0",
69
73
  "acorn": "^8.17.0",
70
74
  "acorn-typescript": "^1.4.13",
@@ -74,7 +78,7 @@
74
78
  "sass": "^1.101.0"
75
79
  },
76
80
  "peerDependencies": {
77
- "@gjsify/lightningcss-native": "^0.52.0",
81
+ "@gjsify/lightningcss-native": "^0.54.0",
78
82
  "rolldown": "^1.1.4"
79
83
  },
80
84
  "peerDependenciesMeta": {
@@ -86,8 +90,8 @@
86
90
  }
87
91
  },
88
92
  "devDependencies": {
89
- "@gjsify/cli": "^0.52.0",
90
- "@gjsify/unit": "^0.52.0",
93
+ "@gjsify/cli": "^0.54.0",
94
+ "@gjsify/unit": "^0.54.0",
91
95
  "@types/node": "^25.9.2",
92
96
  "rolldown": "^1.1.4",
93
97
  "typescript": "^6.0.3"