Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Development monorepo for "React Strict DOM".
* [example-ui](https://github.com/facebook/react-strict-dom/blob/main/apps/example-ui)
* [expo-app](https://github.com/facebook/react-strict-dom/tree/main/apps/expo-app)
* [nextjs-app](https://github.com/facebook/react-strict-dom/blob/main/apps/nextjs-app)
* [vite-app](https://github.com/facebook/react-strict-dom/blob/main/apps/vite-app)
* [platform-tests](https://github.com/facebook/react-strict-dom/blob/main/apps/platform-tests)
* `packages`
* Contains the individual packages managed in the monorepo.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/expo-app/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
require('react-strict-dom/postcss-plugin')({
include: [
'src/**/*.{js,jsx,mjs,ts,tsx}',
'../../node_modules/example-ui/**/*.js'
'../../node_modules/example-ui/**/*.jsx'

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.

If this were an actual node_module we'd probably expect everything to have js extensions rather than jsx, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would it be better to include all potential extensions?

'../../node_modules/example-ui/**/*.{js,jsx,mjs,ts,tsx}'

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.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

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.

Yeah let's do that for now

]
}),
require('autoprefixer')
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-app/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
'react-strict-dom/postcss-plugin': {
include: [
'src/**/*.{js,jsx,ts,tsx}',
'../../node_modules/example-ui/**/*.js'
'../../node_modules/example-ui/**/*.jsx'
],
babelConfig: {
babelrc: false,
Expand Down
24 changes: 24 additions & 0 deletions apps/vite-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Comment thread
necolas marked this conversation as resolved.
73 changes: 73 additions & 0 deletions apps/vite-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
18 changes: 18 additions & 0 deletions apps/vite-app/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const dev = process.env.NODE_ENV !== 'production';

export default {
parserOpts: {
plugins: ['typescript', 'jsx']
},
presets: [
[
'react-strict-dom/babel-preset',
{
debug: dev,
dev,
rootDir: process.cwd(),
platform: 'web'
}
]
]
};
23 changes: 23 additions & 0 deletions apps/vite-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import { defineConfig, globalIgnores } from 'eslint/config';

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser
}
}
]);
13 changes: 13 additions & 0 deletions apps/vite-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-app</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions apps/vite-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "vite-app",
"private": true,
"version": "0.0.54",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"example-ui": "0.0.54",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"vite-plugin-babel": "^1.3.2",
"react-strict-dom": "0.0.54"
},
"devDependencies": {
"autoprefixer": "^10.4.22",
"vite-tsconfig-paths": "^5.1.4",
"@eslint/js": "^9.39.1",
"@types/node": "^24.10.1",
"@types/react": "^19.2.5",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.46.4",
"vite": "^7.2.4"
}
}
14 changes: 14 additions & 0 deletions apps/vite-app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import babelConfig from './babel.config.js';

export default {
plugins: {
'react-strict-dom/postcss-plugin': {
include: [
'src/**/*.{js,jsx,ts,tsx}',
'../../node_modules/example-ui/**/*.jsx'
],
babelConfig
},
autoprefixer: {}
}
};
1 change: 1 addition & 0 deletions apps/vite-app/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions apps/vite-app/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
17 changes: 17 additions & 0 deletions apps/vite-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react'
import { Button, NativeForkButton, PlatformButton, PlatformShell, WebForkButton } from 'example-ui';
import { html } from 'react-strict-dom';

export default function App() {
return (
<React.StrictMode>
<PlatformShell>
<html.p>Hello</html.p>
<Button>Button</Button>
<PlatformButton>PlatformButton</PlatformButton>
<NativeForkButton>NativeForkButton</NativeForkButton>
<WebForkButton>WebForkButton</WebForkButton>
</PlatformShell>
</React.StrictMode>
);
}
1 change: 1 addition & 0 deletions apps/vite-app/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions apps/vite-app/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "@/strict.css";
import App from "@/App.tsx";

createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
</StrictMode>
);
6 changes: 6 additions & 0 deletions apps/vite-app/src/strict.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This directive is used by the react-strict-dom postcss plugin.
* It is automatically replaced with generated CSS during builds.
*/

@react-strict-dom;
34 changes: 34 additions & 0 deletions apps/vite-app/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"moduleSuffixes": [".ios", ".android", ".native", ".web", ""],
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
"allowJs": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"]
}
7 changes: 7 additions & 0 deletions apps/vite-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
26 changes: 26 additions & 0 deletions apps/vite-app/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
Loading