@gjsify/rolldown-plugin-gjsify 0.37.0 → 0.38.1
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/lib/app/gjs.js +18 -10
- package/lib/plugins/css-as-string.js +10 -2
- package/lib/plugins/process-stub.js +27 -1
- package/package.json +7 -7
package/lib/app/gjs.js
CHANGED
|
@@ -104,17 +104,25 @@ export const setupForGjs = async (input) => {
|
|
|
104
104
|
// `require('crypto')`s and cycles back through the @gjsify/crypto alias.
|
|
105
105
|
resolve: {
|
|
106
106
|
mainFields: format === 'esm' ? ['browser', 'module', 'main'] : ['browser', 'main', 'module'],
|
|
107
|
-
//
|
|
108
|
-
//
|
|
107
|
+
// NEITHER 'import' NOR 'require' belongs here — rolldown adds the
|
|
108
|
+
// one matching each CALL SITE, and naming either explicitly applies
|
|
109
|
+
// it to both kinds. The exports-map resolver takes the PACKAGE's
|
|
110
|
+
// first key our list contains, so `'import'` here made a require()
|
|
111
|
+
// call match an `import` key declared first, handing a CJS consumer
|
|
112
|
+
// an ESM namespace where it expects `module.exports`. MEASURED on the
|
|
113
|
+
// express showcase: `is-promise@4` declares `[{import,require,default}, …]`
|
|
114
|
+
// in that order, so `router`'s `require('is-promise')` bound
|
|
115
|
+
// `{default: fn}` and every request threw `TypeError: n is not a
|
|
116
|
+
// function` — answered 200 anyway, and express logged `err.stack`,
|
|
117
|
+
// which carries no message line on SpiderMonkey, so the flagship
|
|
118
|
+
// slide printed ~59 anonymous frames per request naming nothing.
|
|
109
119
|
//
|
|
110
|
-
// `'node'` is
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// `node`
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
// only `unicorn-magic`'s `traversePathUp`) get an explicit alias.
|
|
117
|
-
conditionNames: format === 'esm' ? ['browser', 'import'] : ['browser', 'require', 'import'],
|
|
120
|
+
// `'node'` is absent for a different reason: it hands
|
|
121
|
+
// `cross-fetch-ponyfill` its Node-only entry, which imports
|
|
122
|
+
// `blobFrom`/`fileFrom` and breaks the bundle at link time. Packages
|
|
123
|
+
// that genuinely need their `node` export under GJS (so far only
|
|
124
|
+
// `unicorn-magic`'s `traversePathUp`) get an explicit alias.
|
|
125
|
+
conditionNames: ['browser'],
|
|
118
126
|
},
|
|
119
127
|
transform: {
|
|
120
128
|
// GJS 1.86 / SpiderMonkey 140 ≈ firefox140.
|
|
@@ -331,8 +331,16 @@ let _sassPromise = null;
|
|
|
331
331
|
async function compileSass(filename) {
|
|
332
332
|
if (!_sassPromise) {
|
|
333
333
|
// Lazy + indirect specifier so `sass` is only resolved when a Sass file
|
|
334
|
-
// is actually imported (mirrors the lazy lightningcss backend).
|
|
335
|
-
//
|
|
334
|
+
// is actually imported (mirrors the lazy lightningcss backend).
|
|
335
|
+
//
|
|
336
|
+
// NODE ONLY — this comment used to claim "loads under GJS + Node alike".
|
|
337
|
+
// Measured on 0.37.0: under GJS it rejects with `Module not found: sass` — a
|
|
338
|
+
// BARE specifier resolved at RUNTIME is what GJS's ESM loader cannot do, so
|
|
339
|
+
// `import './x.scss'` fails with UNLOADABLE_DEPENDENCY. Resolving it to a file
|
|
340
|
+
// first (`tryLoadNativeBundler`'s trick) does not help: `sass.default.js` then
|
|
341
|
+
// imports a bare `immutable`. Only INLINING dart-sass works, and 3.6 MB minified
|
|
342
|
+
// onto a 6.6 MB CLI bundle is a carrier-package decision — status/open-todos.md
|
|
343
|
+
// (#1053). dart-sass DOES run under GJS: `adwaita-web`'s `build:scss` does.
|
|
336
344
|
_sassPromise = import(/* @vite-ignore */ 'sass');
|
|
337
345
|
}
|
|
338
346
|
try {
|
|
@@ -18,8 +18,34 @@ export const GJS_PROCESS_STUB = 'if(typeof globalThis.process==="undefined"){' +
|
|
|
18
18
|
// perf-tracking libs, …). Build it as a named local so we can
|
|
19
19
|
// attach the property before stashing it on the stub object.
|
|
20
20
|
'const _h=t=>t?[0,0]:[0,0];_h.bigint=()=>0n;' +
|
|
21
|
+
// `platform`/`arch`, answered LAZILY by the same `uname -sm` probe
|
|
22
|
+
// `@gjsify/process` uses (`packages/node/process/src/internal/uname.ts`),
|
|
23
|
+
// with `@gjsify/utils`' `platform-names.ts` mapping tables inlined minimally
|
|
24
|
+
// — a banner runs before the module system exists and cannot import the
|
|
25
|
+
// canonical ones. Those two are the source of truth; keep this in step or a
|
|
26
|
+
// bundle answers differently depending on whether it pulled
|
|
27
|
+
// `@gjsify/process` in. These used to be the literals `"linux"`/`"x64"`,
|
|
28
|
+
// which is a WRONG answer on two of three OSes rather than a missing one.
|
|
29
|
+
// Lazy, so the cost falls only on a bundle that reads the field AND never
|
|
30
|
+
// loads `@gjsify/process` (whose register replaces this object): nothing is
|
|
31
|
+
// spawned at load. Windows is answered from the environment — `uname` is not
|
|
32
|
+
// on a native Windows PATH, and the env answer is exact.
|
|
33
|
+
'let _pc;const _p=()=>{if(_pc)return _pc;_pc={platform:"linux",arch:"x64"};' +
|
|
34
|
+
'try{' +
|
|
35
|
+
'if(_G.getenv("OS")==="Windows_NT"||_G.getenv("SystemRoot")){' +
|
|
36
|
+
'const a=(_G.getenv("PROCESSOR_ARCHITECTURE")||"").toLowerCase();' +
|
|
37
|
+
'_pc={platform:"win32",arch:a==="arm64"?"arm64":a==="x86"?"ia32":"x64"};return _pc}' +
|
|
38
|
+
'const _r=_G.spawn_sync(null,["uname","-sm"],null,_G.SpawnFlags.SEARCH_PATH,null);' +
|
|
39
|
+
'if(_r&&_r[0]&&_r[1]){const _t=new TextDecoder().decode(_r[1]).trim().split(/\\s+/);' +
|
|
40
|
+
'if(_t.length>1){const s=_t[0],m=_t[_t.length-1].toLowerCase();' +
|
|
41
|
+
'_pc={platform:s==="Linux"?"linux":s==="Darwin"?"darwin":/^CYGWIN/i.test(s)?"cygwin":' +
|
|
42
|
+
'/^(MINGW|MSYS|Windows)/i.test(s)?"win32":s.toLowerCase(),' +
|
|
43
|
+
'arch:m==="x86_64"||m==="amd64"?"x64":m==="aarch64"||m==="arm64"?"arm64":' +
|
|
44
|
+
'/^i[3-6]86$/.test(m)?"ia32":m.startsWith("arm")?"arm":m}}}' +
|
|
45
|
+
'}catch(e){/* no GLib spawn, or spawn refused: the linux/x64 fallback stands */}' +
|
|
46
|
+
'return _pc};' +
|
|
21
47
|
'globalThis.process={' +
|
|
22
|
-
'platform
|
|
48
|
+
'get platform(){return _p().platform},get arch(){return _p().arch},version:"v20.0.0",' +
|
|
23
49
|
'env:new Proxy({},{' +
|
|
24
50
|
'get(_,p){return typeof p==="string"?(_G.getenv(p)??undefined):undefined},' +
|
|
25
51
|
'set(_,p,v){if(typeof p==="string")_G.setenv(p,String(v),true);return true},' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/rolldown-plugin-gjsify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
],
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@gjsify/console": "^0.
|
|
59
|
-
"@gjsify/resolve-npm": "^0.
|
|
60
|
-
"@gjsify/rolldown-plugin-deepkit": "^0.
|
|
61
|
-
"@gjsify/rolldown-plugin-pnp": "^0.
|
|
62
|
-
"@gjsify/vite-plugin-blueprint": "^0.
|
|
58
|
+
"@gjsify/console": "^0.38.1",
|
|
59
|
+
"@gjsify/resolve-npm": "^0.38.1",
|
|
60
|
+
"@gjsify/rolldown-plugin-deepkit": "^0.38.1",
|
|
61
|
+
"@gjsify/rolldown-plugin-pnp": "^0.38.1",
|
|
62
|
+
"@gjsify/vite-plugin-blueprint": "^0.38.1",
|
|
63
63
|
"@rollup/pluginutils": "^5.4.0",
|
|
64
64
|
"acorn": "^8.17.0",
|
|
65
65
|
"acorn-walk": "^8.3.5",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"sass": "^1.101.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@gjsify/lightningcss-native": "^0.
|
|
71
|
+
"@gjsify/lightningcss-native": "^0.38.1",
|
|
72
72
|
"rolldown": "^1.1.4"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|