@ethercorps/sveltekit-og 4.3.0-next.4 → 4.3.0-next.5
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.
|
@@ -18,17 +18,12 @@ export async function useResvg(debug = false) {
|
|
|
18
18
|
log.debug("Initializing Resvg WASM");
|
|
19
19
|
const isWorkerLikeRuntime = isEdgeLight || isWorkerd;
|
|
20
20
|
log.info(`Detected runtime: ${isWorkerLikeRuntime ? "Edge Light or Workerd" : "Node.js"}`);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
resvgInstance.instance = await handleAsync(async () => {
|
|
28
|
-
const mod = await moduleImport;
|
|
29
|
-
return mod.default;
|
|
30
|
-
}, ErrorCodes.RESVG_INIT_FAILED, "Failed to load ReSVG default export");
|
|
31
|
-
await handleAsync(async () => resvgInstance.instance.initWasmPromise, ErrorCodes.RESVG_INIT_FAILED, "Failed to initialize ReSVG WASM");
|
|
21
|
+
// Keep both dynamic imports as direct expressions so the bundler (unwasm/Rollup)
|
|
22
|
+
// can statically analyse them and emit the `?module` wasm chunk correctly.
|
|
23
|
+
// Burying these inside nested async callbacks breaks wasm bundling on Cloudflare.
|
|
24
|
+
const moduleImport = isWorkerLikeRuntime ? import("./resvg/edge.js") : import("./resvg/node.js");
|
|
25
|
+
resvgInstance.instance = await handleAsync(() => moduleImport.then((m) => m.default), ErrorCodes.RESVG_INIT_FAILED, "Failed to import ReSVG module");
|
|
26
|
+
await handleAsync(() => resvgInstance.instance.initWasmPromise, ErrorCodes.RESVG_INIT_FAILED, "Failed to initialize ReSVG WASM");
|
|
32
27
|
return resvgInstance.instance.Resvg;
|
|
33
28
|
}
|
|
34
29
|
export async function useSatori(debug = false) {
|
|
@@ -37,10 +32,7 @@ export async function useSatori(debug = false) {
|
|
|
37
32
|
return satoriInstance.instance.satori;
|
|
38
33
|
}
|
|
39
34
|
log.debug("Initializing Satori WASM");
|
|
40
|
-
satoriInstance.instance = await handleAsync(
|
|
41
|
-
|
|
42
|
-
return mod.default;
|
|
43
|
-
}, ErrorCodes.SATORI_INIT_FAILED, "Failed to load Satori module");
|
|
44
|
-
await handleAsync(async () => satoriInstance.instance.initWasmPromise, ErrorCodes.SATORI_INIT_FAILED, "Failed to initialize Satori WASM");
|
|
35
|
+
satoriInstance.instance = await handleAsync(() => import("./satori/node.js").then((m) => m.default), ErrorCodes.SATORI_INIT_FAILED, "Failed to load Satori module");
|
|
36
|
+
await handleAsync(() => satoriInstance.instance.initWasmPromise, ErrorCodes.SATORI_INIT_FAILED, "Failed to initialize Satori WASM");
|
|
45
37
|
return satoriInstance.instance.satori;
|
|
46
38
|
}
|
|
@@ -5,7 +5,11 @@ export default {
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
initWasmPromise: initWasm(
|
|
7
7
|
// @ts-ignore
|
|
8
|
-
|
|
8
|
+
// Vendored wasm: a relative import resolves inside this package so the
|
|
9
|
+
// consumer's bundler emits a real CompiledWasm module. A bare
|
|
10
|
+
// "@resvg/resvg-wasm/...?module" specifier falls back to runtime byte
|
|
11
|
+
// compilation, which Cloudflare Workers block.
|
|
12
|
+
import("./resvg.wasm?module").then((r) => r.default || r)
|
|
9
13
|
),
|
|
10
14
|
Resvg: _Resvg,
|
|
11
15
|
};
|
|
Binary file
|