You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// for esbuild, use ESM// for zip-it-and-ship-it, use CJS until https://github.com/netlify/zip-it-and-ship-it/issues/750constesm=netlify_config?.functions?.node_bundler==='esbuild';
What I am trying to understand is why, and if it's still required to be this way. It's causing issues for esm only packages (for example any package made with svelte-kit package) because the cjs bundle that uses require is of course unable to import esm.
The esm variable there is used in the netlify adapter, if it's false then esbuild is used to transpile the generated esm by sveltekit into cjs. I am unsure why it needs to be set to esbuild in the netlify.toml because it's a sveltekit adapter doing the transpiling.
What I don't fully understand is where zip-it-and-ship-it comes in or why we are transpiling at all. I also don't understand what parts of netlify do and don't support esm. Hopefully the netlify guys or anyone here will know! I asked @brittneypostma and she is going to get some help from some of the netlify team if possible
Reproduction
I created this repo to show what I mean. It uses a package I made that is esm only. If you remove the netlify.toml OR set the node_bundler to zisi then it will generate CJS and when you visit the site on netlify it breaks
Describe the bug
Currently the netlify adapter builds cjs by default, this is configurable with
functions.node_bundler
in the netlify.toml. The code for that is below:https://github.com/sveltejs/kit/blob/master/packages/adapter-netlify/index.js#L72
What I am trying to understand is why, and if it's still required to be this way. It's causing issues for esm only packages (for example any package made with svelte-kit package) because the cjs bundle that uses
require
is of course unable to import esm.The
esm
variable there is used in the netlify adapter, if it's false then esbuild is used to transpile the generated esm by sveltekit into cjs. I am unsure why it needs to be set to esbuild in thenetlify.toml
because it's a sveltekit adapter doing the transpiling.What I don't fully understand is where
zip-it-and-ship-it
comes in or why we are transpiling at all. I also don't understand what parts of netlify do and don't support esm. Hopefully the netlify guys or anyone here will know! I asked @brittneypostma and she is going to get some help from some of the netlify team if possibleReproduction
I created this repo to show what I mean. It uses a package I made that is esm only. If you remove the netlify.toml OR set the
node_bundler
tozisi
then it will generate CJS and when you visit the site on netlify it breakshttps://github.com/ghostdevv/netlify-sveltekit-esm-only-broke
System Info
Severity
serious, but I can work around it
The text was updated successfully, but these errors were encountered: