@gjsify/rolldown-plugin-gjsify 0.7.2 → 0.7.3

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.
@@ -1,4 +1,5 @@
1
1
  import { BUNDLE_URL_BANNER } from './bundle-url-banner.js';
2
+ import { GJS_WELLKNOWN_SYMBOLS_STUB } from './wellknown-symbols-banner.js';
2
3
  export const GJS_PROCESS_STUB = 'if(typeof globalThis.process==="undefined"){' +
3
4
  'const _s=imports.system,_G=imports.gi.GLib;' +
4
5
  // process.hrtime needs a `.bigint` property attached to the function
@@ -52,8 +53,11 @@ export function composeBanner(stub, userBanner) {
52
53
  }
53
54
  export function processStubPlugin(options = {}) {
54
55
  // The anchor capture must precede the process stub so it runs at the very
55
- // top of the chunk (where `import.meta.url` is the bundle's own URL).
56
- const stub = (options.captureBundleUrl ? BUNDLE_URL_BANNER : '') + GJS_PROCESS_STUB;
56
+ // top of the chunk (where `import.meta.url` is the bundle's own URL). The
57
+ // well-known-symbols polyfill must also run before any module init, so it
58
+ // joins the byte-1 banner. All three pieces are single-line (no source-map
59
+ // drift) and idempotent.
60
+ const stub = (options.captureBundleUrl ? BUNDLE_URL_BANNER : '') + GJS_WELLKNOWN_SYMBOLS_STUB + GJS_PROCESS_STUB;
57
61
  const banner = composeBanner(stub, options.userBanner ?? '');
58
62
  return {
59
63
  name: 'gjsify-process-stub',
@@ -0,0 +1 @@
1
+ export declare const GJS_WELLKNOWN_SYMBOLS_STUB: string;
@@ -0,0 +1,27 @@
1
+ // One-line banner that polyfills the Explicit Resource Management well-known
2
+ // symbols `Symbol.dispose` / `Symbol.asyncDispose` on GJS.
3
+ //
4
+ // GJS / SpiderMonkey (through gjs 1.88) does not expose these symbols, yet the
5
+ // `using` / `await using` syntax is downleveled by tsc, esbuild, babel and bun
6
+ // to a helper that resolves them as:
7
+ //
8
+ // Symbol.dispose || Symbol.for("Symbol.dispose")
9
+ // Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")
10
+ //
11
+ // i.e. they fall back to the GLOBAL-REGISTRY symbol when the native one is
12
+ // missing. The disposable OBJECTS those helpers consume are, however, built
13
+ // with computed members like `{ [Symbol.dispose]() {} }` — and when
14
+ // `Symbol.dispose` is `undefined` that member lands under the string key
15
+ // "undefined", so the helper's `Symbol.for("Symbol.dispose")` lookup misses and
16
+ // throws `Object not disposable`.
17
+ //
18
+ // Defining the symbols as the registered symbols makes both sides agree:
19
+ // object construction and helper lookup resolve to the very same symbol. It
20
+ // must run before any module init (npm packages build disposable singletons at
21
+ // top level), so it ships as part of the byte-1 GJS banner alongside the
22
+ // process stub.
23
+ //
24
+ // Kept on a single line: the banner runs before any source-map-aware machinery,
25
+ // so newlines here would shift every bundle line number by one.
26
+ export const GJS_WELLKNOWN_SYMBOLS_STUB = 'if(!Symbol.dispose)Symbol.dispose=Symbol.for("Symbol.dispose");' +
27
+ 'if(!Symbol.asyncDispose)Symbol.asyncDispose=Symbol.for("Symbol.asyncDispose");';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -51,11 +51,11 @@
51
51
  ],
52
52
  "license": "MIT",
53
53
  "dependencies": {
54
- "@gjsify/console": "^0.7.2",
55
- "@gjsify/resolve-npm": "^0.7.2",
56
- "@gjsify/rolldown-plugin-deepkit": "^0.7.2",
57
- "@gjsify/rolldown-plugin-pnp": "^0.7.2",
58
- "@gjsify/vite-plugin-blueprint": "^0.7.2",
54
+ "@gjsify/console": "^0.7.3",
55
+ "@gjsify/resolve-npm": "^0.7.3",
56
+ "@gjsify/rolldown-plugin-deepkit": "^0.7.3",
57
+ "@gjsify/rolldown-plugin-pnp": "^0.7.3",
58
+ "@gjsify/vite-plugin-blueprint": "^0.7.3",
59
59
  "@rollup/pluginutils": "^5.4.0",
60
60
  "acorn": "^8.16.0",
61
61
  "acorn-walk": "^8.3.5",
@@ -63,7 +63,7 @@
63
63
  "lightningcss": "^1.32.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@gjsify/lightningcss-native": "^0.7.2",
66
+ "@gjsify/lightningcss-native": "^0.7.3",
67
67
  "rolldown": "^1.1.0"
68
68
  },
69
69
  "peerDependenciesMeta": {