Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for esbuild-wasm #342

Open
jdalton opened this issue Jun 22, 2022 · 4 comments
Open

add support for esbuild-wasm #342

jdalton opened this issue Jun 22, 2022 · 4 comments

Comments

@jdalton
Copy link

jdalton commented Jun 22, 2022

Would adding esbuild-wasm as a peer-dependency and loading esbuild as:

function requireEsbuild() {
  let error;
  try {
    return require('esbuild');
  } catch (e) {
    error = e;
  }
  try {
    return require('esbuild-wasm');
  } catch {}
  throw error;
}
@curran
Copy link

curran commented Aug 15, 2023

I'm also interested in making rollup-plugin-esbuild work in the browser using esbuild-wasm.

@sxzz
Copy link
Collaborator

sxzz commented Sep 20, 2023

We'd like to accept this feature if anyone can make a PR for it.

@curran
Copy link

curran commented Oct 31, 2023

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.

@curran
Copy link

curran commented Oct 31, 2023

For a browser build we'd also need to remove these dependencies:

import { existsSync, statSync } from 'fs'
import { extname, resolve, dirname, join } from 'path'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants