Skip to content

Commit c9a2cdb

Browse files
authored
chore: fallback to wasm (#1196)
* chore: fallback to wasm * fixup! * fixup!
1 parent b8d7b77 commit c9a2cdb

5 files changed

Lines changed: 159 additions & 68 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@doc-kit/generator-react': patch
3+
---
4+
5+
Fall back on platforms without native Rolldown or Lightning CSS bindings

‎packages/react/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
"@node-core/ui-components": "^1.8.1",
4040
"@orama/orama": "^3.1.18",
4141
"@orama/ui": "^1.5.4",
42+
"@rolldown/binding-wasm32-wasi": "~1.2.15",
4243
"estree-util-to-js": "^2.0.0",
4344
"github-slugger": "^2.0.0",
4445
"hast-util-to-html": "^9.0.5",
4546
"hast-util-to-string": "^3.0.1",
4647
"hastscript": "^9.0.1",
48+
"lightningcss-wasm": "^1.33.0",
4749
"mdast-util-slice-markdown": "^2.0.1",
4850
"preact": "^10.29.7",
4951
"preact-render-to-string": "^6.7.0",

‎packages/react/src/html/bundlers/vite.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { readFile, rm, rmdir } from 'node:fs/promises';
22
import { dirname, join, posix, resolve } from 'node:path';
33
import { fileURLToPath, pathToFileURL } from 'node:url';
44

5+
import './wasm-fallback.mjs';
56
import {
67
build as viteBuild,
78
defaultClientConditions,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { registerHooks } from 'node:module';
2+
3+
if (process.arch === 'ppc64' || process.arch === 's390x') {
4+
const url = import.meta.resolve('lightningcss-wasm');
5+
6+
registerHooks({
7+
/**
8+
* Resolves `lightningcss` to `lightningcss-wasm`.
9+
*
10+
* @type {import('node:module').ResolveHookSync}
11+
*/
12+
resolve: (specifier, context, nextResolve) =>
13+
specifier === 'lightningcss'
14+
? { url, format: 'module', shortCircuit: true }
15+
: nextResolve(specifier, context),
16+
});
17+
}

0 commit comments

Comments
 (0)