@sveltejs/adapter-cloudflare-workers
Advanced tools
Comparing version 1.0.0-next.15 to 1.0.0-next.16
# @sveltejs/adapter-cloudflare-workers | ||
## 1.0.0-next.16 | ||
### Patch Changes | ||
- e6995797: feat(adapters): expose esbuild configuration | ||
## 1.0.0-next.15 | ||
@@ -4,0 +10,0 @@ |
17
index.js
@@ -7,3 +7,12 @@ import fs from 'fs'; | ||
export default function () { | ||
/** | ||
* @typedef {import('esbuild').BuildOptions} BuildOptions | ||
*/ | ||
/** | ||
* @param {{ | ||
* esbuild?: (defaultOptions: BuildOptions) => Promise<BuildOptions> | BuildOptions; | ||
* }} options | ||
**/ | ||
export default function (options = { esbuild: (opts) => opts }) { | ||
/** @type {import('@sveltejs/kit').Adapter} */ | ||
@@ -33,3 +42,3 @@ const adapter = { | ||
await esbuild.build({ | ||
const buildOptions = await options.esbuild({ | ||
entryPoints: ['.svelte-kit/cloudflare-workers/entry.js'], | ||
@@ -39,5 +48,7 @@ outfile: `${entrypoint}/index.js`, | ||
target: 'es2020', | ||
platform: 'node' // TODO would be great if we could generate ESM and use type = "javascript" | ||
platform: 'browser' // TODO would be great if we could generate ESM and use type = "javascript" | ||
}); | ||
await esbuild.build(buildOptions); | ||
fs.writeFileSync(`${entrypoint}/package.json`, JSON.stringify({ main: 'index.js' })); | ||
@@ -44,0 +55,0 @@ |
{ | ||
"name": "@sveltejs/adapter-cloudflare-workers", | ||
"version": "1.0.0-next.15", | ||
"version": "1.0.0-next.16", | ||
"type": "module", | ||
@@ -19,3 +19,3 @@ "exports": { | ||
"devDependencies": { | ||
"@sveltejs/kit": "1.0.0-next.126" | ||
"@sveltejs/kit": "1.0.0-next.131" | ||
}, | ||
@@ -22,0 +22,0 @@ "scripts": { |
@@ -7,3 +7,3 @@ # adapter-cloudflare-workers | ||
## Configuration | ||
## Basic Configuration | ||
@@ -30,4 +30,35 @@ This adapter expects to find a [wrangler.toml](https://developers.cloudflare.com/workers/platform/sites/configuration) file in the project root. It will determine where to write static assets and the worker based on the `site.bucket` and `site.entry-point` settings. | ||
## Advanced Configuration | ||
### esbuild | ||
As an escape hatch, you may optionally specify a function which will receive the final esbuild options generated by this adapter and returns a modified esbuild configuration. The result of this function will be passed as-is to esbuild. The function can be async. | ||
For example, you may wish to add a plugin: | ||
```js | ||
adapterCfw({ | ||
esbuild(defaultOptions) { | ||
return { | ||
...defaultOptions, | ||
plugins: [] | ||
}; | ||
} | ||
}); | ||
``` | ||
The default options for this version are as follows: | ||
```js | ||
{ | ||
entryPoints: ['.svelte-kit/cloudflare-workers/entry.js'], | ||
outfile: `${entrypoint}/index.js`, | ||
bundle: true, | ||
target: 'es2020', | ||
platform: 'browser' | ||
} | ||
``` | ||
## Changelog | ||
[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/adapter-cloudflare-workers/CHANGELOG.md). |
10828
146
63