@gjsify/rolldown-native 0.4.42 → 0.4.44

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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @gjsify/rolldown-native
2
+
3
+ A native Rust cdylib + Vala/GObject bridge that wraps the Rust `rolldown` bundler and exposes it to GJS via `gi://`. This is the default bundler engine used by `gjsify build` under GJS — npm's `rolldown` is an N-API addon that cannot load in GJS, so this bridge is how gjsify bundles without a Node runtime. Includes a complete plugin bridge (`bundleWithPlugins`) for load, transform, resolveId, and render-chunk hooks. Ships prebuilt `.so` + `.typelib` for Linux.
4
+
5
+ Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ gjsify install @gjsify/rolldown-native
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { hasNativeRolldown, bundle, bundleWithPlugins } from '@gjsify/rolldown-native';
17
+
18
+ if (hasNativeRolldown()) {
19
+ // Simple bundle
20
+ const result = bundle({
21
+ input: [{ import: 'src/index.ts' }],
22
+ format: 'esm',
23
+ minify: false,
24
+ });
25
+ for (const item of result.output) {
26
+ if (item.type === 'chunk') console.log(item.fileName, item.code.length, 'bytes');
27
+ }
28
+ }
29
+ ```
30
+
31
+ Under normal usage `@gjsify/rolldown-native` is consumed automatically by the gjsify CLI (`gjsify build`) — direct use is only needed when embedding the bundler in custom build tooling.
32
+
33
+ ## License
34
+
35
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-native",
3
- "version": "0.4.42",
3
+ "version": "0.4.44",
4
4
  "description": "Phase D-2 POC: Vala/GObject + Rust cdylib bridge to rolldown for GJS. Wraps `rolldown::Bundler::generate()` (async, tokio) in a per-call current-thread runtime so JS sees a sync `bundle()` call. JSON-encoded BundlerOptions in, JSON-encoded BundleOutput out — the boundary stays small even though rolldown's option surface is enormous. POC scope: no JS plugins (Phase B), no watch/HMR, no incremental builds. Companion to `@gjsify/lightningcss-native`; together they remove the last two Rust-crate runtime blockers from the gjsify build pipeline (Phase D-3 unblock).",
5
5
  "type": "module",
6
6
  "main": "lib/esm/index.js",
@@ -47,7 +47,7 @@
47
47
  "@girs/gobject-2.0": "2.88.0-4.0.4"
48
48
  },
49
49
  "devDependencies": {
50
- "@gjsify/cli": "^0.4.42",
50
+ "@gjsify/cli": "^0.4.44",
51
51
  "@types/node": "^25.9.1",
52
52
  "typescript": "^6.0.3"
53
53
  },
@@ -175,9 +175,18 @@ gjsify_rolldown_glue_session_take_request_payload (BundleSession *session,
175
175
  if (session == NULL) return NULL;
176
176
  size_t len = 0;
177
177
  uint8_t *buf = gjsify_rolldown_session_take_request_payload (session, req_id, &len);
178
- if (buf == NULL || len == 0) return NULL;
178
+ /* NULL buf = no payload was stashed for this req_id (genuine miss) NULL.
179
+ * A non-NULL buf with len == 0 is an EMPTY-but-present payload (e.g. the
180
+ * `transform` hook on rolldown's virtual `\0rolldown/empty.js` module, whose
181
+ * code is ""). It MUST yield an empty GBytes, NOT NULL — otherwise the JS
182
+ * adapter reads `take_request_payload() === null` and throws "missing payload
183
+ * bytes", which is exactly what broke the CLI self-build. Don't fold len==0
184
+ * into the miss case. */
185
+ if (buf == NULL) return NULL;
179
186
  /* Copy into GLib heap and free the Rust allocation immediately so
180
- * GBytes refcount/lifetime stays inside the GLib side. */
187
+ * GBytes refcount/lifetime stays inside the GLib side. g_bytes_new copies
188
+ * `len` bytes; for len == 0 it never dereferences `buf`, so the Rust
189
+ * dangling-but-aligned zero-length pointer is safe here. */
181
190
  GBytes *out = g_bytes_new (buf, len);
182
191
  gjsify_rolldown_session_free_payload (buf, len);
183
192
  return out;