Menci / vite-plugin-wasm

Add WebAssembly ESM integration (aka. Webpack's `asyncWebAssembly`) to Vite and support `wasm-pack` generated modules.
MIT License
281 stars 16 forks source link

default import is undefined (bun) #39

Closed eye-wave closed 9 months ago

eye-wave commented 12 months ago

wasm is undefined when using bun v1.0.0

command used: $ bun run "$(bun pm bin)/vite" dev

failed to load config from .../my-project/vite.config.ts error when starting dev server: TypeError: wasm is not a function. (In 'wasm()', 'wasm' is undefined) at module code (.../my-project/vite.config.ts.timestamp-....mjs:7:11) at processTicksAndRejections (:1:1302) error: script "dev" exited with code 1 (SIGHUP)

config file

// vite.config.ts
import { defineConfig } from "vite"
import { sveltekit } from "@sveltejs/kit/vite"
import wasm from "vite-plugin-wasm";

export default defineConfig({
  plugins: [sveltekit(),wasm()],
})

standalone bun example

import * as wasm from "vite-plugin-wasm"

console.log(wasm)
// results:

// Bun:
// Module {
//   default: undefined
// }

// Node:
// [Module: null prototype] { default: [Function: wasm] }
//
zavx0z commented 9 months ago

https://github.com/oven-sh/bun/issues/7146

Menci commented 9 months ago

See also my comments in https://github.com/oven-sh/bun/issues/7146#issuecomment-1848883257.