@gjsify/rolldown-plugin-gjsify 0.4.43 → 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,45 @@
1
+ # @gjsify/rolldown-plugin-gjsify
2
+
3
+ The core Rolldown plugin set powering `gjsify build`. Orchestrates per-target app builds for GJS, Node, Browser, and NativeScript — handling Node↔GJS module aliasing, automatic globals injection (`--globals auto`), CSS-as-string loading (via `@gjsify/lightningcss-native` or the npm fallback), platform-file resolution (`.android.ts` / `.ios.ts`), process-stub injection, shebang hoisting, and more.
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-plugin-gjsify
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Typically consumed via the gjsify CLI (`gjsify build --app gjs`). For direct use in a custom Rolldown config:
16
+
17
+ ```typescript
18
+ import rolldown from 'rolldown';
19
+ import { setupForGjs } from '@gjsify/rolldown-plugin-gjsify';
20
+
21
+ const { options, plugins } = await setupForGjs({
22
+ input: 'src/index.ts',
23
+ globals: 'auto',
24
+ });
25
+
26
+ const build = await rolldown({ ...options, plugins });
27
+ await build.write({ file: 'dist/app.gjs.mjs' });
28
+ ```
29
+
30
+ Individual plugins are also exported for use in custom pipelines:
31
+
32
+ ```typescript
33
+ import {
34
+ cssAsStringPlugin,
35
+ gjsImportsEmptyPlugin,
36
+ processStubPlugin,
37
+ shebangPlugin,
38
+ textLoaderPlugin,
39
+ platformResolvePlugin,
40
+ } from '@gjsify/rolldown-plugin-gjsify';
41
+ ```
42
+
43
+ ## License
44
+
45
+ MIT
package/lib/app/gjs.js CHANGED
@@ -20,10 +20,10 @@ import { processStubPlugin } from '../plugins/process-stub.js';
20
20
  import { cssAsStringPlugin } from '../plugins/css-as-string.js';
21
21
  import { shebangPlugin, resolveShebangLine, inputShebangStripPlugin } from '../plugins/shebang.js';
22
22
  const _shimDir = dirname(fileURLToPath(import.meta.url));
23
- function resolveConsoleShim() {
23
+ function resolveShim(shimName) {
24
24
  // Preferred: relative to this module's directory. Works under the
25
25
  // normal Node consumer flow where `_shimDir` = `<pkg>/lib/app/`.
26
- const relative = resolve(_shimDir, '../shims/console-gjs.js');
26
+ const relative = resolve(_shimDir, `../shims/${shimName}.js`);
27
27
  let fs = null;
28
28
  try {
29
29
  // eslint-disable-next-line @typescript-eslint/no-require-imports
@@ -38,13 +38,14 @@ function resolveConsoleShim() {
38
38
  // (GJS-CLI self-host loop) `_shimDir` collapses to the bundle's
39
39
  // own directory and the relative lookup misses. createRequire's
40
40
  // resolver is `exports`-map-aware (Phase C), so the published
41
- // subpath export `./shims/console-gjs` works under both Node and
42
- // GJS without further walking.
41
+ // subpath export `./shims/<name>` works under both Node and GJS
42
+ // without further walking. Each shim MUST be a `./shims/<name>`
43
+ // subpath export in package.json for this fallback to resolve.
43
44
  try {
44
45
  // eslint-disable-next-line @typescript-eslint/no-require-imports
45
46
  const Module = require('node:module');
46
47
  const require_ = Module.createRequire(import.meta.url);
47
- return require_.resolve('@gjsify/rolldown-plugin-gjsify/shims/console-gjs');
48
+ return require_.resolve(`@gjsify/rolldown-plugin-gjsify/shims/${shimName}`);
48
49
  }
49
50
  catch {
50
51
  return relative;
@@ -91,7 +92,7 @@ export const setupForGjs = async (input) => {
91
92
  // around `conditionNames` below). Route the package to our
92
93
  // bundled shim so the API is reachable under --app gjs without
93
94
  // turning on the node condition globally.
94
- const unicornMagicShim = resolve(_shimDir, '../shims/unicorn-magic.js');
95
+ const unicornMagicShim = resolveShim('unicorn-magic');
95
96
  const aliasMap = {
96
97
  ...getAliasesForGjs({ external }),
97
98
  'unicorn-magic': unicornMagicShim,
@@ -109,7 +110,7 @@ export const setupForGjs = async (input) => {
109
110
  // resolution lands at a non-existent location. Walk up via
110
111
  // createRequire's node_modules-aware resolver as a fallback.
111
112
  const consoleShimEnabled = input.pluginOptions.consoleShim !== false;
112
- const consoleShimPath = consoleShimEnabled ? resolveConsoleShim() : null;
113
+ const consoleShimPath = consoleShimEnabled ? resolveShim('console-gjs') : null;
113
114
  // The auto-globals inject stub (when present) is side-effect-imported
114
115
  // via a virtual entry — its register modules write to globalThis, so
115
116
  // the import chain matters but no name binding does. We can't use
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.4.43",
3
+ "version": "0.4.44",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -20,6 +20,9 @@
20
20
  },
21
21
  "./shims/module-resolve": {
22
22
  "default": "./lib/shims/module-resolve.js"
23
+ },
24
+ "./shims/unicorn-magic": {
25
+ "default": "./lib/shims/unicorn-magic.js"
23
26
  }
24
27
  },
25
28
  "files": [
@@ -48,11 +51,11 @@
48
51
  ],
49
52
  "license": "MIT",
50
53
  "dependencies": {
51
- "@gjsify/console": "^0.4.43",
52
- "@gjsify/resolve-npm": "^0.4.43",
53
- "@gjsify/rolldown-plugin-deepkit": "^0.4.43",
54
- "@gjsify/rolldown-plugin-pnp": "^0.4.43",
55
- "@gjsify/vite-plugin-blueprint": "^0.4.43",
54
+ "@gjsify/console": "^0.4.44",
55
+ "@gjsify/resolve-npm": "^0.4.44",
56
+ "@gjsify/rolldown-plugin-deepkit": "^0.4.44",
57
+ "@gjsify/rolldown-plugin-pnp": "^0.4.44",
58
+ "@gjsify/vite-plugin-blueprint": "^0.4.44",
56
59
  "@rollup/pluginutils": "^5.4.0",
57
60
  "acorn": "^8.16.0",
58
61
  "acorn-walk": "^8.3.5",
@@ -60,7 +63,7 @@
60
63
  "lightningcss": "^1.32.0"
61
64
  },
62
65
  "peerDependencies": {
63
- "@gjsify/lightningcss-native": "^0.4.43",
66
+ "@gjsify/lightningcss-native": "^0.4.44",
64
67
  "rolldown": "^1.0.3"
65
68
  },
66
69
  "peerDependenciesMeta": {