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(@react-router/dev): add defineConfig utility #12541

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

AlemTuzlak
Copy link
Contributor

Create a vite style defineConfig so you can do something like:

import { defineConfig } from "@react-router/dev/config";

export default defineConfig({
  // stuff
})

Copy link

changeset-bot bot commented Dec 13, 2024

⚠️ No Changeset found

Latest commit: d85aed1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@AlemTuzlak AlemTuzlak changed the title Feat/add define config feat: add define config Dec 13, 2024
@MichaelDeBoey MichaelDeBoey changed the title feat: add define config feat(@react-router/dev): add defineConfig utility Dec 13, 2024
Copy link
Member

@markdalgleish markdalgleish left a comment

Choose a reason for hiding this comment

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

We went back and forth on whether to add this, but we ultimately decided against it because it adds needless indirection, even though the syntax does look nicer to my eyes.

A defineConfig function arguably makes it look like there's some kind of runtime behaviour supported here, or that it may be introduced in the future, but if it's only used to perform type checking, it felt simpler and more transparent to simply annotate the type.

Curious to hear your thoughts on this though.

@AlemTuzlak
Copy link
Contributor Author

@rossipedia pinging you so you can leave thoughts as well, but here are mine:

I think this is more of a "standards" thing in my eyes, as the react-router plugin relies on Vite, and wraps it with with a custom command I'd expect for it to have similar config definition to Vite, something like Vitest does, I understand they integrate tightly and are built by the same people, but I feel like this function definition has become something you expect to see in the Vite ecosystem.

Another thing I'd like to mention is that there are certain config flags, even though they don't provide runtime behaviors, they do provide buildtime behaviors like onBuildEnd etc. I agree that at the moment there is no runtime behavior but you never know if there will be some, also this would easily allow you to wrap the Vite defineConfig and do something like:

import { defineConfig } from "@react-router/dev/config";

export default defineConfig({
  vite: {
     // ... vite stuff here ...
  },
  future: {
    // RSC WHEN?!?!?
  }
})

I personally feel like it's just a convinience 1 liner utility that feels warm and familiar compared to 1 million custom configs like eslint, biome, insert random json config file here. It takes 0 maintainence as it just inherits the type you have to define and manage anyway and it feels more in line with Vite.

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.

3 participants