deno_emit
deno_emit copied to clipboard
Deno.emit() allow specifying "externals" that should not be bundled.
I'm trying to create a bundle for my frontend app with Deno.emit()
. I'm using a bunch of dependencies from jspm which I don't want to include into the bundle and let the browser import them instead. This would allow me to leverage the caching benefits coming from using a CDN.
swc_bundler
that's used under the hood in Deno.emit()
already supports it: https://github.com/swc-project/swc/blob/4e7723a7a0286f49124e7dc1ca10668ad6a237a9/bundler/src/bundler/mod.rs#L34 so it should be pretty straight-forward to add it to Deno. I'm also happy to take on this if you are happy with the proposal.
I was thinking about adding the external_modules
option to EmitOptions
that mimics one of swc_bundler
and accepts an array of absolutely resolved module specifiers but I think a better option could be a function that gets the module specifier in and tells if it should be external or not.
Maybe it can be the same load
function proposed here: https://github.com/denoland/deno/issues/9866 but using some special return value indicating the module import should be left intact. What do you think?
It is strongly related to denoland/deno#9866, but there has been some debate internally with the core team about the roadmap with Deno.emit()
. I plan to come up with a stronger proposal in the very near future and will include trying to address this use case as part of that proposal. We need to get alignment with the general direction with Deno.emit()
before anyone expends any effort trying to implement more features.