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

When using file loaders, processResult throws an error #45

Open
thatsmydoing opened this issue Feb 22, 2022 · 2 comments
Open

When using file loaders, processResult throws an error #45

thatsmydoing opened this issue Feb 22, 2022 · 2 comments

Comments

@thatsmydoing
Copy link

When using an esbuild config with file loaders, the result.outputFiles may contain files other than the sourcemap and resulting js.

This causes an error here

karma-esbuild/src/bundle.ts

Lines 153 to 154 in bcf9982

const map = JSON.parse(result.outputFiles[0].text) as RawSourceMap;
const source = result.outputFiles[1];
when it tries to parse some other file as a sourcemap and fails

@jridgewell
Copy link
Collaborator

Do you have an example of how to reproduce this? I'm not sure what file loader you're referencing.

@thatsmydoing
Copy link
Author

I meant this one https://esbuild.github.io/content-types/#external-file

So you could do

import url from "./somefile.txt";

and configure esbuild with

require('esbuild').buildSync({
  entryPoints: ['app.js'],
  bundle: true,
  loader: { '.txt': 'file' },
  outdir: 'out',
})

and it should output both the bundle and the .txt file into out

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