feat(adapters): expose esbuild configuration#1914
Merged
Conversation
🦋 Changeset detectedLatest commit: 1eac54c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
esbuildoption for these adapters:adapter-cloudflare-workersadapter-netlifyadapter-nodeadapter-vercelThe 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
platformforadapter-cloudflare-workershas 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 testand lint the project withpnpm lintandpnpm checkChangesets
pnpx changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0