diff --git a/.changeset/silly-ears-visit.md b/.changeset/silly-ears-visit.md new file mode 100644 index 000000000000..75bca012fc7f --- /dev/null +++ b/.changeset/silly-ears-visit.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-vercel': patch +--- + +fix: include the `edge-light` bundling condition when building edge functions diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index 257383302658..a1f141d3bc12 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -137,9 +137,19 @@ const plugin = function (defaults = {}) { const result = await esbuild.build({ entryPoints: [`${tmp}/edge.js`], outfile: `${dirs.functions}/${name}.func/index.js`, - target: 'es2020', // TODO verify what the edge runtime supports + // minimum Node.js version supported is v14.6.0 that is mapped to ES2019 + // https://edge-runtime.vercel.app/features/polyfills + // TODO verify the latest ES version the edge runtime supports + target: 'es2020', bundle: true, platform: 'browser', + conditions: [ + // Vercel's Edge runtime key https://runtime-keys.proposal.wintercg.org/#edge-light + 'edge-light', + // re-include these since they are included by default when no conditions are specified + // https://esbuild.github.io/api/#conditions + 'module' + ], format: 'esm', external: [ ...compatible_node_modules,