feat(adapters): expose esbuild configuration #1914
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Currently, the esbuild instance of all official adapters are locked down. This makes it impossible to override default settings, inject shims, use plugins, etc. While we should strive to have a great out-of-the-box experience for the majority of users, there's always an edge case which we cannot include by default for various reasons, be it performance or build times or bundle size penalties.
This PR adds a new
esbuild
option for these adapters:adapter-cloudflare-workers
adapter-netlify
adapter-node
adapter-vercel
The option is a function which receives an esbuild configuration and is expected to return the final esbuild configuration to be passed as-is to esbuild. The function can be async.
Additionally, the default
platform
foradapter-cloudflare-workers
has been swapped tobrowser
, instead ofnode
, which much better resembles the target platform, especially for dependency resolution.Why not a config object that gets merged?
Some options require information computed by the adapter that the user may need to modify instead of outright replace. For example, the user may want to completely overwrite the injected shims array, or they may want to add to it. A config merge cannot do both, it can only perform one of those behaviors. This also avoids having to explicitly whitelist "allowed" configuration values esbuild may add in the future.
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0