Skip to content

Convert Vite plugin adapter API to presets - #8620

Merged
pcattori merged 28 commits into
devfrom
markdalgleish/adapter-config
Jan 31, 2024
Merged

pcattori merged 28 commits into
devfrom
markdalgleish/adapter-config

Conversation

@markdalgleish

@markdalgleish markdalgleish commented Jan 29, 2024 •

Copy link
Copy Markdown
Member

This PR makes the following changes:

  • Expands the adapter API into a more general presets API, supporting an array of preset objects that can define config to be merged with defaults before the user config is applied at the end.
  • Removes the loadContext and viteConfig options from the old adapter API.
  • Converts the Cloudflare adapter into a preset.
  • Adds a remixConfigResolved hook to the preset which provides support for config validation after all presets have been applied.
  • Adds a required name property to presets so that we can roll out improved error messaging support to the new remixConfigResolved hook in the future.
  • Makes the buildEnd option available as a top-level option, not just for adapters.

Note that the documentation for preset authors is pretty light right now while this feature is still fresh. I'll add more docs as a follow-up, but the priority is to get this out for now.

@changeset-bot

changeset-bot Bot commented Jan 29, 2024 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 08ebfc2

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

This PR includes changesets to release 16 packages
Name Type
@remix-run/dev Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/node Patch
@remix-run/react Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/testing 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

@markdalgleish markdalgleish changed the title Support all config values in Vite adapter Convert Vite plugin adapter API to presets Jan 31, 2024
@markdalgleish
markdalgleish marked this pull request as ready for review January 31, 2024 02:40
Comment thread packages/remix-dev/vite/plugin.ts Outdated
Comment thread packages/remix-dev/vite/plugin.ts
Comment on lines +473 to +477
...(mergeRequired("presets")
? {
presets: [...(configA.presets ?? []), ...(configB.presets ?? [])],
}
: {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to support merging presets. Presets should all be declared upfront. That could also simplify updateRemixPluginContext where omit is called for presets key.

@markdalgleish markdalgleish Jan 31, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is currently not used since we never attempt to merge two configs that both have presets. Currently only user configs can have them. I only included it here for completeness in case this function ever ends up being public API.

@pcattori
pcattori merged commit 44bac29 into dev Jan 31, 2024
@pcattori
pcattori deleted the markdalgleish/adapter-config branch January 31, 2024 16:05
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hello there,

We just published version 2.6.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions

github-actions Bot commented Feb 1, 2024

Copy link
Copy Markdown
Contributor

🤖 Hello there,

We just published version 2.6.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants