webview-bun
webview-bun copied to clipboard
Bytecode compilation is not supported
- run build script
bun build --compile --minify --sourcemap ./examples/basic.ts --outfile ./dist/basic --bytecode
- get error
this why? https://bun.sh/docs/bundler/executables#bytecode-compilation
From the bun docs, it's mentioned that bytecode compilation is experimental and only works with cjs. So if you somehow transpile this library to cjs, you could make it work.
Though there are no plans to support this right now, I'm keeping the issue open.
I understand, you are correct. But there is no need to convert to cjs somehow, because when compiling with bytecode, the conversion is performed inside bun.
The core reasons for this are
- when bytecode is enabled, bun compiles the source code into cjs
- the use of the top-level-wait syntax in the source code is a hindrance.
So not using the top-level-wait syntax allows bytecode to work correctly.
It would be possible to rewrite the top-level-wait as an async function, but that would make the entire call chain asynchronous.
But the bytecode feature is experimental, so I agree with you to keep this issue