Open jdalton opened 2 years ago
I'm also interested in making rollup-plugin-esbuild
work in the browser using esbuild-wasm
.
We'd like to accept this feature if anyone can make a PR for it.
Wouldn't it be more like this?
async function requireEsbuild() {
try {
return await import('esbuild');
} catch (error) {
try {
return await import('esbuild-wasm');
} catch {
throw error;
}
}
}
Alternatively, what if we allowed consumers to provide their own instance of ESBuild in the plugin constructor? That would allow consumers of the plugin to import ESBuild-WASM however they like.
For a browser build we'd also need to remove these dependencies:
import { existsSync, statSync } from 'fs'
import { extname, resolve, dirname, join } from 'path'
Would adding
esbuild-wasm
as a peer-dependency and loading esbuild as: