Skip to content

Commit

Permalink
feat: add support for wasm loader
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Jul 14, 2023
1 parent e075476 commit f223465
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"chokidar": "^3.5.3",
"cpy": "^10.1.0",
"esbuild": "0.18.11",
"esbuild-plugin-wasm": "^1.1.0",
"events": "^3.3.0",
"execa": "^7.1.1",
"globby": "^13.2.1",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import polka from 'polka'
import { createRequire } from 'module'
import { fileURLToPath, pathToFileURL } from 'url'
import * as DefaultRunners from '../test-runners.js'
import { wasmLoader } from 'esbuild-plugin-wasm'

const require = createRequire(import.meta.url)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
Expand Down Expand Up @@ -434,7 +435,7 @@ await import('${require
sourcemap: 'inline',
platform: 'browser',
format: 'esm',
plugins: [nodePlugin, watchPlugin],
plugins: [nodePlugin, watchPlugin, wasmLoader()],
outfile: outPath,
inject: [path.join(__dirname, 'inject-process.js')],
define: {
Expand Down Expand Up @@ -520,7 +521,11 @@ export async function resolveModule(id, base = process.cwd()) {
const url = pathToFileURL(path)
return await import(url.href)
} catch (error) {
throw new Error(`Cannot resolve module "${id}" from "${base}"\n${/** @type {Error} */(error).message}`)
throw new Error(
`Cannot resolve module "${id}" from "${base}"\n${
/** @type {Error} */ (error).message
}`
)
}
}

Expand Down

0 comments on commit f223465

Please sign in to comment.