@gjsify/rolldown-plugin-gjsify 0.4.14 → 0.4.16

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.
@@ -36,6 +36,9 @@
36
36
  // `GJSIFY_CSS_BACKEND={native|npm}` to force a specific backend
37
37
  // (mainly useful for benchmarking + the integration suite).
38
38
  import { readFile } from 'node:fs/promises';
39
+ import { createRequire } from 'node:module';
40
+ import { dirname, isAbsolute, resolve as resolvePath } from 'node:path';
41
+ import { pathToFileURL } from 'node:url';
39
42
  let _bundlerPromise = null;
40
43
  async function pickBundler() {
41
44
  const forced = globalThis.process?.env?.GJSIFY_CSS_BACKEND;
@@ -93,10 +96,39 @@ async function loadNpmBundler() {
93
96
  targets,
94
97
  minify: false,
95
98
  errorRecovery: true,
99
+ resolver: cssBundleResolver,
96
100
  });
97
101
  return { code: result.code };
98
102
  };
99
103
  }
104
+ // lightningcss `bundleAsync` resolver — adds npm-package-specifier support
105
+ // to `@import` statements. Without a resolver, lightningcss only walks
106
+ // relative + absolute paths; bare package specifiers (`@scope/pkg/file.css`
107
+ // or `pkg-name/file.css`) hit ENOENT.
108
+ //
109
+ // This restores the @import-from-node_modules behavior that the old
110
+ // `@gjsify/esbuild-plugin-css` shipped with — needed by every consumer
111
+ // monorepo that puts shared CSS in a workspace package (e.g.
112
+ // pixel-rpg/map-editor's `@import "@pixelrpg/gjs/index.css"`).
113
+ //
114
+ // Algorithm mirrors Node's standard module-resolution algorithm so that
115
+ // `exports` maps in the target package.json are honored (e.g.
116
+ // `@pixelrpg/gjs` exposes `./index.css` via its exports field — that
117
+ // must resolve through `package.json#exports`, not a direct file probe).
118
+ const cssBundleResolver = {
119
+ resolve(specifier, from) {
120
+ if (isAbsolute(specifier))
121
+ return specifier;
122
+ if (specifier.startsWith('./') || specifier.startsWith('../')) {
123
+ return resolvePath(dirname(from), specifier);
124
+ }
125
+ // Bare specifier — walk node_modules and honor package.json exports.
126
+ // `createRequire` takes a file URL or path; passing the importer
127
+ // lets it scope its node_modules walk to the right starting point.
128
+ const req = createRequire(pathToFileURL(from).href);
129
+ return req.resolve(specifier);
130
+ },
131
+ };
100
132
  function targetsToBrowserslist(targets) {
101
133
  if (!targets)
102
134
  return undefined;
@@ -1,5 +1,10 @@
1
1
  export const GJS_PROCESS_STUB = 'if(typeof globalThis.process==="undefined"){' +
2
2
  'const _s=imports.system,_G=imports.gi.GLib;' +
3
+ // process.hrtime needs a `.bigint` property attached to the function
4
+ // itself (Node API shape: `process.hrtime.bigint()` — used by execa,
5
+ // perf-tracking libs, …). Build it as a named local so we can
6
+ // attach the property before stashing it on the stub object.
7
+ 'const _h=t=>t?[0,0]:[0,0];_h.bigint=()=>0n;' +
3
8
  'globalThis.process={' +
4
9
  'platform:"linux",arch:"x64",version:"v20.0.0",' +
5
10
  'env:new Proxy({},{' +
@@ -17,7 +22,7 @@ export const GJS_PROCESS_STUB = 'if(typeof globalThis.process==="undefined"){' +
17
22
  'stderr:{write(s){printerr(s)}},stdout:{write(s){print(s)}},stdin:null,' +
18
23
  'exitCode:undefined,' +
19
24
  'nextTick(fn,...a){Promise.resolve().then(()=>fn(...a))},' +
20
- 'hrtime(t){return t?[0,0]:[0,0]},' +
25
+ 'hrtime:_h,' +
21
26
  '};' +
22
27
  '}';
23
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -45,11 +45,11 @@
45
45
  ],
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@gjsify/console": "^0.4.14",
49
- "@gjsify/resolve-npm": "^0.4.14",
50
- "@gjsify/rolldown-plugin-deepkit": "^0.4.14",
51
- "@gjsify/rolldown-plugin-pnp": "^0.4.14",
52
- "@gjsify/vite-plugin-blueprint": "^0.4.14",
48
+ "@gjsify/console": "^0.4.16",
49
+ "@gjsify/resolve-npm": "^0.4.16",
50
+ "@gjsify/rolldown-plugin-deepkit": "^0.4.16",
51
+ "@gjsify/rolldown-plugin-pnp": "^0.4.16",
52
+ "@gjsify/vite-plugin-blueprint": "^0.4.16",
53
53
  "@rollup/pluginutils": "^5.3.0",
54
54
  "acorn": "^8.16.0",
55
55
  "acorn-walk": "^8.3.5",
@@ -57,7 +57,7 @@
57
57
  "lightningcss": "^1.32.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@gjsify/lightningcss-native": "^0.4.14",
60
+ "@gjsify/lightningcss-native": "^0.4.16",
61
61
  "rolldown": "^1.0.0-rc.18"
62
62
  },
63
63
  "peerDependenciesMeta": {