Skip to content

Commit

Permalink
Init Wasm module only once in browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Oct 27, 2023
1 parent 0cc21e8 commit 48af744
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions wasm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { await_promise_sync, createBundleAsync } from './async.mjs';
let wasm, bundleAsyncInternal;

export default async function init(input) {
if (wasm) return;

input = input ?? new URL('lightningcss_node.wasm', import.meta.url);
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
input = fetchOrReadFromFs(input);
Expand Down

0 comments on commit 48af744

Please sign in to comment.