-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: support esbuild #46
Conversation
1: |
About 2, 3: plugin authors just returns the sourcemap, without saying what kind of code it is. (Is it js or css?) code += `\n//# sourceMappingURL=${map.toUrl()}`
// this only work if code is js
// in css we should use `/*#` style I may assume that plugins only returns javascript. In fact I don't know what other bundlers handle file types. |
About 4: esbuild do merge source maps if the result in const { code, map: map1 } = await plugin.load(id)
const { code: result, map: map2 } = await plugin.transform(code)
return { result, map: ? } |
I think authors should filter out the types that are not js (so they still have the chance to process them if they absolutely want). Could be better to mention that in the docs. 4: then for sure we should merge it |
@antfu I have tested (a little) against your awesome |
CI failed, can you have a look? |
This is because Maybe we should guess the loader by ourself. |
Let's have the default |
A bit more thinking: maybe we should use JSX as default since some users may write jsx in .js files. 🤔 But I'd like to keep it as is until someone come to ask for this feat 😆 |
This pr adds esbuild support for unplugin, which resolves #25 .
Some Todos:
peerDependencies
?load
andtransform
are always js variants (js, jsx, ts, tsx) then append the sourcemap url to the code.onLoad
callback will be applied to all kind of resources, including the binary ones (images, etc.). So the plugin has a chance to handle them too. Plugin authors need to make sure the result of theload
andtransform
are valid javascript code.plugin.load
andplugin.transform
both returns code and map, we merge the two sourcemaps if both present. Otherwise only the last one will be kept.Hope to hear your thoughts!