From 31205d3ffc4010252fa90f0cced7c6f751b7f771 Mon Sep 17 00:00:00 2001 From: Juan Manuel Villacorta Campos Date: Tue, 30 Aug 2022 04:53:25 +0000 Subject: [PATCH 1/2] Fix `global is not defined` on vercel edge --- .changeset/rare-wolves-deliver.md | 5 +++++ packages/adapter-vercel/index.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/rare-wolves-deliver.md diff --git a/.changeset/rare-wolves-deliver.md b/.changeset/rare-wolves-deliver.md new file mode 100644 index 000000000000..a9a669e5edc7 --- /dev/null +++ b/.changeset/rare-wolves-deliver.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-vercel': patch +--- + +Fix `global is not defined` runtime error building with `edge: true` option diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index 0d0ba443385c..b545f2acb033 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -189,7 +189,8 @@ export default function ({ external = [], edge, split } = {}) { platform: 'browser', format: 'esm', external, - sourcemap: 'linked' + sourcemap: 'linked', + banner: { js: 'var global = globalThis;' } }); write( From 41d9c8dc1c3bfb3747a372426519c182622d5ecf Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 30 Aug 2022 09:05:54 -0400 Subject: [PATCH 2/2] Update packages/adapter-vercel/index.js --- packages/adapter-vercel/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index b545f2acb033..37027c836f7a 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -190,7 +190,7 @@ export default function ({ external = [], edge, split } = {}) { format: 'esm', external, sourcemap: 'linked', - banner: { js: 'var global = globalThis;' } + banner: { js: 'globalThis.global = globalThis;' } }); write(