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

Convert Vite plugin adapter API to presets #8620

Merged
merged 28 commits into from
Jan 31, 2024
Merged

Conversation

markdalgleish
Copy link
Member

@markdalgleish markdalgleish commented Jan 29, 2024

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.

Copy link

changeset-bot bot commented Jan 29, 2024

🦋 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 on lines +473 to +477
...(mergeRequired("presets")
? {
presets: [...(configA.presets ?? []), ...(configB.presets ?? [])],
}
: {}),
Copy link
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.

Copy link
Member Author

@markdalgleish markdalgleish Jan 31, 2024

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
9 checks passed
@pcattori pcattori deleted the markdalgleish/adapter-config branch January 31, 2024 16:05
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Jan 31, 2024
Copy link
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!

Copy link
Contributor

github-actions bot commented Feb 1, 2024

🤖 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!

@github-actions github-actions bot removed the awaiting release This issue has been fixed and will be released soon label Feb 1, 2024
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