Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(adapters): expose esbuild configuration #1914

Merged
merged 1 commit into from
Jul 18, 2021
Merged

Conversation

GrygrFlzr
Copy link
Member

@GrygrFlzr GrygrFlzr commented Jul 15, 2021

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 for adapter-cloudflare-workers has been swapped to browser, instead of node, 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

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jul 15, 2021

🦋 Changeset detected

Latest commit: 1eac54c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@sveltejs/adapter-cloudflare-workers Patch
@sveltejs/adapter-netlify Patch
@sveltejs/adapter-node Patch
@sveltejs/adapter-vercel Patch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect kit.vite.esbuild config when building with Vercel adapter
2 participants