Skip to content

Commit

Permalink
[fix] set platform to neutral for cloudflare build (#8083)
Browse files Browse the repository at this point in the history
* [fix] set platform to neutral for cloudflare build

* set esbuild platform to neutral

* consolidate changesets

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
benmccann and Rich-Harris authored Dec 12, 2022
1 parent ba95b64 commit ee7cd45
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .changeset/chilly-pumas-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@sveltejs/adapter-cloudflare': patch
'@sveltejs/adapter-cloudflare-workers': patch
'@sveltejs/adapter-netlify': patch
'@sveltejs/adapter-vercel': patch
---

[fix] set esbuild platform to neutral
7 changes: 4 additions & 3 deletions packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ export default function ({ config = 'wrangler.toml' } = {}) {
);

await esbuild.build({
platform: 'browser',
platform: 'neutral',
mainFields: ['module', 'main'],
conditions: ['worker'],
sourcemap: 'linked',
target: 'es2020',
entryPoints: [`${tmp}/entry.js`],
outfile: main,
bundle: true,
external: ['__STATIC_CONTENT_MANIFEST'],
format: 'esm'
external: ['__STATIC_CONTENT_MANIFEST']
});

builder.log.minor('Copying assets...');
Expand Down
5 changes: 3 additions & 2 deletions packages/adapter-cloudflare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ export default function () {
});

await esbuild.build({
platform: 'browser',
platform: 'neutral',
mainFields: ['module', 'main'],
conditions: ['worker'],
sourcemap: 'linked',
target: 'es2020',
entryPoints: [`${tmp}/_worker.js`],
outfile: `${dest}/_worker.js`,
allowOverwrite: true,
format: 'esm',
bundle: true
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ async function generate_edge_functions({ builder }) {
);

await esbuild.build({
platform: 'neutral',
mainFields: ['module', 'main'],
entryPoints: [`${tmp}/entry.js`],
outfile: '.netlify/edge-functions/render.js',
bundle: true,
format: 'esm',
platform: 'browser',
sourcemap: 'linked',
target: 'es2020'
});
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ const plugin = function ({ external = [], edge, split } = {}) {
);

await esbuild.build({
platform: 'neutral',
mainFields: ['module', 'main'],
entryPoints: [`${tmp}/edge.js`],
outfile: `${dirs.functions}/${name}.func/index.js`,
target: 'es2020', // TODO verify what the edge runtime supports
bundle: true,
platform: 'browser',
format: 'esm',
external,
sourcemap: 'linked',
banner: { js: 'globalThis.global = globalThis;' }
Expand Down

0 comments on commit ee7cd45

Please sign in to comment.