Menci/vite-plugin-wasm

RollupError: "default" is not exported by "node_modules/..."

happysalada opened this issue · 3 comments

hey, using this and trying to load a wasm file, I'm getting the following stack trace

error during build:
RollupError: "default" is not exported by "node_modules/.pnpm/@dqbd+tiktoken@1.0.7/node_modules/@dqbd/tiktoken/lite/tiktoken_bg.wasm", imported by "src/routes/+page.server.ts".
    at error (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:2125:30)
    at Module.error (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:13452:16)
    at Module.traceVariable (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:13863:29)
    at ModuleScope.findVariable (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:12418:39)
    at ReturnValueScope.findVariable (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:6966:38)
    at ChildScope.findVariable (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:6966:38)
    at BlockScope.findVariable (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:6966:38)
    at ReturnValueScope.findVariable (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:6966:38)
    at Identifier.bind (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:8116:40)
    at CallExpression.bind (file:///Users/raphael/dev/glad-chat/node_modules/.pnpm/rollup@3.21.5/node_modules/rollup/dist/es/shared/node-entry.js:5735:28)
 ELIFECYCLE  Command failed with exit code 1.

and I'm trying to

import { Tiktoken, init } from "@dqbd/tiktoken/lite/init";
import wasm from "@dqbd/tiktoken/lite/tiktoken_bg.wasm";
import model from "@dqbd/tiktoken/encoders/cl100k_base.json";
             await init((imports) => WebAssembly.instantiate(wasm, imports));
	    const encoder = new Tiktoken(
	      model.bpe_ranks,
	      model.special_tokens,
	      model.pat_str
	    );

any pointers would be amazing.

Menci commented

Could you please provide a simple project to reproduce it? Thanks.

Thanks for coming by, here is the repo where the error happens https://github.com/happysalada/glad-chat
running a pnpm run build should trigger the error.

Thanks a lot for the maintenance of this plugin!

Menci commented

Explained in #33 (comment).