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

relative path cause invalid path error when used in build in browser #693

Closed
hardfist opened this issue Jan 19, 2021 · 2 comments
Closed

Comments

@hardfist
Copy link
Contributor

when I use esbuild in browser, if outfile is relative path (even though write is false) will cause error, which seems caused by golang doesn't implement fs.stat when target GOOS=js

async function main() {
  const service = await esbuild.startService({
    wasmURL: 'https://unpkg.com/esbuild-wasm@0.8.33/esbuild.wasm',
  });
  const result = await service.build({
    stdin: {
      contents: `const x = 1`,
    },
    write: false,
    outfile: 'esbuild.js',
  });
  console.log('result:', result);
}

main();

image

@evanw
Copy link
Owner

evanw commented Jan 22, 2021

Thanks for the heads up. For now, I believe a workaround is to use an absolute path. I need to figure out what to do about paths with WebAssembly. It turns out Go's path library is pretty broken when targeting WebAssembly so I may need to fork the standard library and implement path manipulation myself. Fixing that would make it easy to fix this too.

evanw added a commit that referenced this issue Jan 26, 2021
@evanw
Copy link
Owner

evanw commented Jan 26, 2021

This should be fixed as of version 0.8.35.

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

2 participants