Hi, I'm moving to Bun bundling instead of my current webpack bundling at my frontend application. I encountered an error when trying to serve the dist, the error is
Uncaught TypeError: import_W3CEBNF.default.Parser is not a constructor
It comes from the following code in one of my dependencies dependencies
import EBNF from "ebnf/dist/Grammars/W3CEBNF";
import { jsonQueryGrammar } from "./jsonQueryGrammar";
...
const parser = new EBNF.Parser(jsonQueryGrammar);
(The dependencies are [email protected] > @sagold/[email protected])
I assume it is some sort of ESM / CJS error, but I have no idea how to fix it, maybe its a configuration issue, or if it's even not fixable and I need to use a replacement package?
My tsconfig is (based on the recommended one in the docs):
tsconfig
The build I do via code:
import { build } from "bun";
console.log("Building client...");
build({
experimentalCss: true,
entrypoints: ["./src/index.ts", "./src/okta.index.ts"],
outdir: "./dist",
sourcemap: "inline",
})
.then(console.log)
.catch(error => console.error(error));
versions of stuff:
Bun: 1.1.38
Typescript: 5.7.2
OS: Ubuntu 22.04.5 LTS (WSL)
Also, if you have any general tips and common errors when moving from webpack to bun I would love to hear them!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.