Support file loader?
saitonakamura opened this issue · comments
I use it in pair with uvu to transpile typescript. When I'm trying to test a file than imports, for instance, a png file (which is set up as --loader:.png=file
in my esbuild cli), node throws with
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".png" for /blabla/star.png
at defaultGetFormat (internal/modules/esm/get_format.js:71:15)
at getFormat (file://node_modules/esbuild-node-loader/loader.mjs:162:10)
It's obviously not a problem of this loader, but I'm stuggling to understand how to properly apporach it. Since esbuild supports file loader, maybe it makes sense to somehow support it inside this loader? Or it's better to chain loaders via https://github.com/lukeed/loadr and provide some fake one for certain extensions. I'd appreciate some guidance
@saitonakamura
AFAIK,
- Similar thing
http protocol
https://github.com/antfu/esbuild-node-loader/blob/main/loader.mjs#L100
add new extension .mts
https://github.com/antfu/esbuild-node-loader/blob/main/loader.mjs#L10
- There is not yet able to chain loaders, written nodejs v1 and v2 api loader api
Oh, that was dumb of me to assume it worked. I only tested with a single loader.
Thanks, will revisit later. Hopefully it'll be part of the redesign.
- Maybe someone can chain up multiple custom loader api, expose to one v2 loader api? Have't seen one yet.