Add Vite, TanStack Start and Typescript environment setup configuration to the documentation#433
Add Vite, TanStack Start and Typescript environment setup configuration to the documentation#433Dovakeidy wants to merge 7 commits into
Conversation
…on standards and Vite expectations
…solving and update README with the new examples
|
Hi @Dovakeidy! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
necolas
left a comment
There was a problem hiding this comment.
Thanks! The Vite example and docs look good. But I don't think we need a TanStack app - it looks like it's just a Vite app. The setup instructions are only really needed for bundlers/frameworks
| --- | ||
| slug: /learn/setup-typescript | ||
| --- | ||
|
|
||
| # Typescript | ||
|
|
||
| <p className="text-xl">Learn how to configure Typescript for React Strict DOM.</p> | ||
|
|
||
| ## About Typescript | ||
|
|
||
| [TypeScript](https://www.typescriptlang.org/) is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. | ||
|
|
||
| ## Platform-specific files | ||
|
|
||
| React Strict DOM supports creating separate implementations for different platforms—such as web and native using platform-specific file extensions (e.g., `.web.tsx`, `.native.tsx`). This approach allows you to write custom code for each platform while sharing a single codebase. To ensure TypeScript correctly resolves these files during development and builds, you can use the `moduleSuffixes` option in your `tsconfig.json`. The following configuration tells TypeScript to prioritize platform-specific files when resolving imports: | ||
|
|
||
| ```json title="tsconfig.json" | ||
| { | ||
| "compilerOptions": { | ||
| "moduleSuffixes": [".ios", ".android", ".native", ".web", ""], | ||
| // ... | ||
| }, | ||
| // ... | ||
| } | ||
| ``` |
There was a problem hiding this comment.
There is already a part of the Expo setup docs that covers the ts configuration needed for cross-platform file extensions. I'm not sure we need a docs page just for ts. If other stacks (only targeting web) still need this ts config, we can put it into their setup docs so everything is in one place.
| include: [ | ||
| 'src/**/*.{js,jsx,mjs,ts,tsx}', | ||
| '../../node_modules/example-ui/**/*.js' | ||
| '../../node_modules/example-ui/**/*.jsx' |
There was a problem hiding this comment.
If this were an actual node_module we'd probably expect everything to have js extensions rather than jsx, right?
There was a problem hiding this comment.
Would it be better to include all potential extensions?
'../../node_modules/example-ui/**/*.{js,jsx,mjs,ts,tsx}'
There was a problem hiding this comment.
Not sure. As far I'm aware the norm is publishing js or mjs files to npm. Maybe needing to add source file extensions like jsx is a quirk of the monorepo
There was a problem hiding this comment.
I completely overlooked the fact that it was the Expo app's postcss configuration and not the documentation. I changed it to .jsx here because I had to modify all the extensions of the “example-ui” app to .jsx in order to align with React and Vite conventions (Vite does not accept JSX on a .js file).
So, in my opinion, we should leave .jsx here so that the example apps work, but use .js in the documentation:
'node_modules/<package-name>/*.js'
What do you think?
Would you prefer that I completely remove the app / the TanStack Start documentation, and the TypeScript documentation? |
|
Yes please Thanks for figuring out how to integrate RSD with Vite and creating the Vite example. Really good for the library and a big help Still open to things like having dedicated TS docs if there is more to document. (And TS help in general. Meta doesn't use them and this repo doesn't test them |
|
Okay @necolas , anything else to change before merging? |
|
Merged! Thanks again! |
|
I was about to do some testing because I am having performance issue currently (mostly postcss plugin being REALLY slow) and wanted to see how the vite example from this PR works and I am getting this issues: |
|
It's strange that it worked one day, I don't understand. You can fix this by including example-ui in the babel configuration. Can you confirm that it works so that I can make the change? Thank you! vite.config.ts react({
babel: {
configFile: true
},
include: ['example-ui'] // <===
}), |
|
Just to let you know, I had to add into I found what caused my performance issue (misconfigured postcss glob with */ which cause a terrible experience). I have no issue with my current setup which includes some tweaks (probably unncessary in RSD repo since I guess RSD itself isn't really a normal "node_modules) export default defineConfig({
// ...
plugins: [
//...
viteReact({
babel: { configFile: true },
exclude: [/\/node_modules\/(?!react-strict-dom)/], // necessary
}),
],
ssr: {
noExternal: ["react-strict-dom"], // necessary
},
optimizeDeps: {
exclude: ["react-strict-dom"], // necessary
},
});Any reason you skipped those ? I suspect this could cause trouble to new comers. |
|
@MoOx |
|
Yeah it's working but hot reloading isn't but it seems related to the internal setup. @necolas not sure if that's the case but maybe "apps" folder should be part of CI at some point to be sure the actual example works ? |
cc @necolas @MoOx
This PR is a follow-up to this comment
Description
This pull request introduces several important improvements related to integrating React Strict DOM with modern tooling commonly used across the React ecosystem.
Added documentation
I added new documentation sections covering:
The goal is to provide clear guidance on how to set up React Strict DOM with these tools, without requiring developers to piece together information from issues or trial-and-error.
Context: multiple issues related to Vite configuration
Several existing issues report problems with Vite configuration.
Issue #273
Issue #265
This highlights the need for an official, working example, especially since Vite and TanStack Start are among the most widely used tools in the ecosystem outside of Next.js.
Adoption concern
I believe the lack of documentation and examples for these technologies is currently a significant barrier to adopting React Strict DOM.
This PR aims to reduce that friction and provide a straightforward and reproducible setup path.
Renaming .js to .jsx in the example components
I also renamed all example UI components from .js to .jsx because: