diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 22ad9c813..e83ecf546 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,6 +1,6 @@ name: "\U0001F680 New feature proposal" description: Propose a new feature -labels: ["pending triage"] +labels: ['pending triage'] type: Feature body: - type: markdown @@ -25,7 +25,7 @@ body: id: feature-description attributes: label: Description - description: "Clear and concise description of the problem. Please make the reason and usecases as detailed as possible. If you intend to submit a PR for this issue, tell us in the description. Thanks!" + description: 'Clear and concise description of the problem. Please make the reason and usecases as detailed as possible. If you intend to submit a PR for this issue, tell us in the description. Thanks!' placeholder: As a developer using Vite I want [goal / wish] so that [benefit]. validations: required: true @@ -33,7 +33,7 @@ body: id: suggested-solution attributes: label: Suggested solution - description: "In module [xy] we could provide following implementation..." + description: 'In module [xy] we could provide following implementation...' validations: required: true - type: textarea diff --git a/.github/renovate.json5 b/.github/renovate.json5 index d777dbf4a..0c80f9f04 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,57 +1,57 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:recommended", "schedule:weekly", "group:allNonMajor"], - "labels": ["dependencies"], - "ignorePaths": ["**/__tests__/**"], - "rangeStrategy": "bump", - "packageRules": [ + $schema: 'https://docs.renovatebot.com/renovate-schema.json', + extends: ['config:recommended', 'schedule:weekly', 'group:allNonMajor'], + labels: ['dependencies'], + ignorePaths: ['**/__tests__/**'], + rangeStrategy: 'bump', + packageRules: [ { - "matchDepTypes": ["peerDependencies"], - "enabled": false, + matchDepTypes: ['peerDependencies'], + enabled: false, }, { - "matchFileNames": ["**/react-18/**", "**/compiler-react-18/**"], - "ignoreDeps": ["react", "react-dom", "@types/react", "@types/react-dom"], + matchFileNames: ['**/react-18/**', '**/compiler-react-18/**'], + ignoreDeps: ['react', 'react-dom', '@types/react', '@types/react-dom'], }, { - "extends": ["monorepo:swc"], - "groupName": "swc monorepo", - "separateMajorMinor": false, + extends: ['monorepo:swc'], + groupName: 'swc monorepo', + separateMajorMinor: false, }, // renovate doesn't properly handle x.x.x-beta-hash-yyyymm version schema { - "matchPackageNames": [ - "react-compiler-runtime", - "babel-plugin-react-compiler", + matchPackageNames: [ + 'react-compiler-runtime', + 'babel-plugin-react-compiler', ], - "followTag": "latest", + followTag: 'latest', }, { - "matchDepTypes": ["action"], - "pinDigests": true, - "matchPackageNames": ["!actions/{/,}**", "!github/{/,}**"], + matchDepTypes: ['action'], + pinDigests: true, + matchPackageNames: ['!actions/{/,}**', '!github/{/,}**'], }, { - "groupName": "react-related dependencies", - "matchPackageNames": [ - "react", - "react-dom", - "@types/react", - "@types/react-dom", - "react-refresh", - "react-server-dom-webpack", - "use-sync-external-store", + groupName: 'react-related dependencies', + matchPackageNames: [ + 'react', + 'react-dom', + '@types/react', + '@types/react-dom', + 'react-refresh', + 'react-server-dom-webpack', + 'use-sync-external-store', ], }, ], - "ignoreDeps": [ + ignoreDeps: [ // manually bumping - "node", + 'node', // breaking changes - "source-map", // `source-map:v0.7.0+` needs more investigation - "kill-port", // `kill-port:^2.0.0 has perf issues (#8392) + 'source-map', // `source-map:v0.7.0+` needs more investigation + 'kill-port', // `kill-port:^2.0.0 has perf issues (#8392) - "prettier", // waiting for stable choice on ternaries + 'prettier', // waiting for stable choice on ternaries ], } diff --git a/.github/workflows/ci-rsc.yml b/.github/workflows/ci-rsc.yml index 5d70841d0..3f0f004c3 100644 --- a/.github/workflows/ci-rsc.yml +++ b/.github/workflows/ci-rsc.yml @@ -9,12 +9,12 @@ on: - main pull_request: paths: - - "packages/plugin-rsc/**" - - "pnpm-lock.yaml" - - ".github/workflows/ci-rsc.yml" + - 'packages/plugin-rsc/**' + - 'pnpm-lock.yaml' + - '.github/workflows/ci-rsc.yml' schedule: # Run daily at 00:00 UTC to test canary/experimental React versions - - cron: "0 0 * * *" + - cron: '0 0 * * *' concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.sha }} @@ -42,7 +42,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] browser: [chromium] rolldown: [false] - react_version: [""] + react_version: [''] include: - os: ubuntu-latest browser: firefox diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 841f94148..793070f81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ env: # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources NODE_OPTIONS: --max-old-space-size=6144 # install playwright binary manually (because pnpm only runs install script once) - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' # Vitest auto retry on flaky segfault VITEST_SEGFAULT_RETRY: 3 @@ -38,7 +38,7 @@ jobs: node_version: 22 fail-fast: false - name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" + name: 'Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}' steps: - name: Checkout uses: actions/checkout@v6 @@ -107,7 +107,7 @@ jobs: if: github.repository == 'vitejs/vite-plugin-react' timeout-minutes: 10 runs-on: ubuntu-latest - name: "Lint: node-20, ubuntu-latest" + name: 'Lint: node-20, ubuntu-latest' steps: - uses: actions/checkout@v6 with: @@ -131,7 +131,7 @@ jobs: run: pnpm run lint - name: Check formatting - run: pnpm prettier --check . + run: pnpm format --check - name: Typecheck run: pnpm run typecheck diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 9e56f0a71..039af3e0c 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -1,6 +1,6 @@ # https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment -name: "Copilot Setup Steps" +name: 'Copilot Setup Steps' on: workflow_dispatch: diff --git a/.github/workflows/issue-close-require.yml b/.github/workflows/issue-close-require.yml index 20bce6818..4e1d5547b 100644 --- a/.github/workflows/issue-close-require.yml +++ b/.github/workflows/issue-close-require.yml @@ -2,7 +2,7 @@ name: Issue Close Require on: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' jobs: close-issues: @@ -15,7 +15,7 @@ jobs: - name: need reproduction uses: actions-cool/issues-helper@e2ff99831a4f13625d35064e2b3dfe65c07a0396 # v3 with: - actions: "close-issues" + actions: 'close-issues' token: ${{ secrets.GITHUB_TOKEN }} - labels: "need reproduction" + labels: 'need reproduction' inactive-day: 3 diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml index e6b68fbe7..9d39dcadf 100644 --- a/.github/workflows/issue-labeled.yml +++ b/.github/workflows/issue-labeled.yml @@ -16,29 +16,29 @@ jobs: if: github.event.label.name == 'contribution welcome' || github.event.label.name == 'help wanted' uses: actions-cool/issues-helper@e2ff99831a4f13625d35064e2b3dfe65c07a0396 # v3 with: - actions: "create-comment, remove-labels" + actions: 'create-comment, remove-labels' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} body: | Hello @${{ github.event.issue.user.login }}. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it! - labels: "pending triage, need reproduction" + labels: 'pending triage, need reproduction' - name: remove pending if: (github.event.label.name == 'enhancement' || contains(github.event.label.description, '(priority)')) && contains(github.event.issue.labels.*.name, 'pending triage') uses: actions-cool/issues-helper@e2ff99831a4f13625d35064e2b3dfe65c07a0396 # v3 with: - actions: "remove-labels" + actions: 'remove-labels' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} - labels: "pending triage" + labels: 'pending triage' - name: need reproduction if: github.event.label.name == 'need reproduction' uses: actions-cool/issues-helper@e2ff99831a4f13625d35064e2b3dfe65c07a0396 # v3 with: - actions: "create-comment, remove-labels" + actions: 'create-comment, remove-labels' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} body: | Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://vite.new). Issues marked with `need reproduction` will be closed if they have no activity within 3 days. - labels: "pending triage" + labels: 'pending triage' diff --git a/.github/workflows/lock-closed-issues.yml b/.github/workflows/lock-closed-issues.yml index b23bae42f..5876d0cbf 100644 --- a/.github/workflows/lock-closed-issues.yml +++ b/.github/workflows/lock-closed-issues.yml @@ -2,7 +2,7 @@ name: Lock Closed Issues on: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' permissions: issues: write @@ -15,10 +15,10 @@ jobs: - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5 with: github-token: ${{ secrets.GITHUB_TOKEN }} - issue-inactive-days: "14" + issue-inactive-days: '14' #issue-comment: | # This issue has been locked since it has been closed for more than 14 days. # # If you have found a concrete bug or regression related to it, please open a new [bug report](https://github.com/vitejs/vite-plugin-react/issues/new/choose) with a reproduction against the latest Vite version. If you have any other comments you should join the chat at [Vite Land](https://chat.vite.dev) or create a new [discussion](https://github.com/vitejs/vite-plugin-react/discussions). - issue-lock-reason: "" - process-only: "issues" + issue-lock-reason: '' + process-only: 'issues' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 06e404554..24d29df89 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,7 +3,7 @@ name: Publish Package on: push: tags: - - "plugin-*" + - 'plugin-*' jobs: publish: @@ -33,7 +33,7 @@ jobs: - name: Install deps run: pnpm install env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' - name: Get pkgName for tag id: tag diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 000000000..594e030b4 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,20 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "semi": false, + "singleQuote": true, + "printWidth": 80, + "experimentalSortImports": { + "newlinesBetween": false, + "partitionByNewline": true, + "groups": [["builtin"], ["external"]] + }, + "ignorePatterns": [ + "packages/*/CHANGELOG.md", + "playground-temp/", + "dist/", + "temp/", + "LICENSE.md", + "pnpm-lock.yaml", + "pnpm-workspace.yaml" + ] +} diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index e7938c738..000000000 --- a/.prettierignore +++ /dev/null @@ -1,7 +0,0 @@ -packages/*/CHANGELOG.md -playground-temp/ -dist/ -temp/ -LICENSE.md -pnpm-lock.yaml -pnpm-workspace.yaml diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 6a3a2f9ac..000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "semi": false, - "singleQuote": true, - "overrides": [ - { - "files": ["*.json5"], - "options": { - "singleQuote": false, - "quoteProps": "preserve" - } - }, - { - "files": ["*.yml"], - "options": { - "singleQuote": false - } - } - ] -} diff --git a/eslint.config.js b/eslint.config.js index 1b2ff21dc..a8b61bf44 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,11 +1,11 @@ // @ts-check import { builtinModules } from 'node:module' import eslint from '@eslint/js' -import pluginN from 'eslint-plugin-n' import pluginImportX from 'eslint-plugin-import-x' +import pluginN from 'eslint-plugin-n' import pluginRegExp from 'eslint-plugin-regexp' -import tseslint from 'typescript-eslint' import globals from 'globals' +import tseslint from 'typescript-eslint' export default tseslint.config( { @@ -103,17 +103,6 @@ export default tseslint.config( { allow: builtinModules.map((mod) => `node:${mod}`) }, ], 'import-x/no-duplicates': 'error', - 'import-x/order': 'error', - 'sort-imports': [ - 'error', - { - ignoreCase: false, - ignoreDeclarationSort: true, - ignoreMemberSort: false, - memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], - allowSeparatedGroups: false, - }, - ], 'regexp/prefer-regexp-exec': 'error', 'regexp/prefer-regexp-test': 'error', diff --git a/package.json b/package.json index f8579fe0e..eca981d51 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,20 @@ { "name": "@vitejs/vite-plugin-react-monorepo", "private": true, - "type": "module", - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "packageManager": "pnpm@10.27.0", - "homepage": "https://github.com/vitejs/vite-plugin-react/", "keywords": [ + "build-tool", + "dev-server", "frontend", "hmr", - "dev-server", - "build-tool", - "vite", - "react" + "react", + "vite" ], + "homepage": "https://github.com/vitejs/vite-plugin-react/", + "type": "module", "scripts": { "preinstall": "npx only-allow pnpm", "postinstall": "simple-git-hooks", - "format": "prettier --write --cache .", + "format": "oxfmt", "lint": "eslint --cache .", "typecheck": "tsc -p scripts && tsc -p playground && tsc -p packages/plugin-react", "test": "pnpm run test-unit && pnpm run test-serve && pnpm run test-build && pnpm --filter ./packages/plugin-react-swc run test", @@ -44,9 +40,9 @@ "fs-extra": "^11.3.3", "globals": "^17.0.0", "lint-staged": "^16.2.7", + "oxfmt": "^0.23.0", "picocolors": "^1.1.1", "playwright-chromium": "^1.57.0", - "prettier": "^3.6.2", "simple-git-hooks": "^2.13.1", "typescript": "^5.9.3", "typescript-eslint": "^8.51.0", @@ -59,7 +55,7 @@ }, "lint-staged": { "*": [ - "prettier --write --cache --ignore-unknown" + "oxfmt --no-error-on-unmatched-pattern" ], "packages/*/{src,types}/**/*.ts": [ "eslint --cache --fix" @@ -70,5 +66,9 @@ "playground/**/__tests__/**/*.ts": [ "eslint --cache --fix" ] - } + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "packageManager": "pnpm@10.27.0" } diff --git a/packages/common/package.json b/packages/common/package.json index 17ac876c5..5336f9f43 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,8 +1,8 @@ { "name": "@vitejs/react-common", "version": "0.0.0", - "type": "module", "private": true, + "type": "module", "exports": { ".": "./index.ts", "./refresh-runtime": "./refresh-runtime.js" diff --git a/packages/common/refresh-utils.ts b/packages/common/refresh-utils.ts index ef9dc00f6..ddd34c633 100644 --- a/packages/common/refresh-utils.ts +++ b/packages/common/refresh-utils.ts @@ -1,5 +1,5 @@ -import type { Plugin } from 'vite' import { exactRegex } from '@rolldown/pluginutils' +import type { Plugin } from 'vite' export const runtimePublicPath = '/@react-refresh' diff --git a/packages/plugin-react-oxc/package.json b/packages/plugin-react-oxc/package.json index a17373d08..786e54e56 100644 --- a/packages/plugin-react-oxc/package.json +++ b/packages/plugin-react-oxc/package.json @@ -1,21 +1,30 @@ { "name": "@vitejs/plugin-react-oxc", "version": "0.4.3", + "description": "The future default Vite plugin for React projects", + "keywords": [ + "fast refresh", + "oxc", + "react", + "react-refresh", + "vite", + "vite-plugin" + ], + "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme", + "bugs": { + "url": "https://github.com/vitejs/vite-plugin-react/issues" + }, "license": "MIT", "author": "Evan You", "contributors": [ "Alec Larson", "Arnaud Barré" ], - "description": "The future default Vite plugin for React projects", - "keywords": [ - "vite", - "vite-plugin", - "react", - "oxc", - "react-refresh", - "fast refresh" - ], + "repository": { + "type": "git", + "url": "git+https://github.com/vitejs/vite-plugin-react.git", + "directory": "packages/plugin-react-oxc" + }, "files": [ "dist" ], @@ -26,27 +35,18 @@ "build": "tsdown", "prepublishOnly": "npm run build" }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vitejs/vite-plugin-react.git", - "directory": "packages/plugin-react-oxc" - }, - "bugs": { - "url": "https://github.com/vitejs/vite-plugin-react/issues" - }, - "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme", - "peerDependencies": { - "vite": "^6.3.0 || ^7.0.0" + "dependencies": { + "@rolldown/pluginutils": "1.0.0-beta.58" }, "devDependencies": { "@vitejs/react-common": "workspace:*", "tsdown": "^0.18.4", "vite": "catalog:rolldown-vite" }, - "dependencies": { - "@rolldown/pluginutils": "1.0.0-beta.58" + "peerDependencies": { + "vite": "^6.3.0 || ^7.0.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" } } diff --git a/packages/plugin-react-oxc/src/index.ts b/packages/plugin-react-oxc/src/index.ts index 3be4046c9..90665ceea 100644 --- a/packages/plugin-react-oxc/src/index.ts +++ b/packages/plugin-react-oxc/src/index.ts @@ -1,14 +1,14 @@ +import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' -import { readFileSync } from 'node:fs' -import type { BuildOptions, Plugin } from 'vite' +import { exactRegex } from '@rolldown/pluginutils' import { addRefreshWrapper, getPreambleCode, runtimePublicPath, silenceUseClientWarning, } from '@vitejs/react-common' -import { exactRegex } from '@rolldown/pluginutils' +import type { BuildOptions, Plugin } from 'vite' const _dirname = dirname(fileURLToPath(import.meta.url)) const refreshRuntimePath = join(_dirname, 'refresh-runtime.js') diff --git a/packages/plugin-react-swc/package.json b/packages/plugin-react-swc/package.json index b214d728c..63b20bb02 100644 --- a/packages/plugin-react-swc/package.json +++ b/packages/plugin-react-swc/package.json @@ -1,43 +1,37 @@ { "name": "@vitejs/plugin-react-swc", "version": "4.2.2", - "license": "MIT", - "author": "Arnaud Barré (https://github.com/ArnaudBarre)", + "private": true, "description": "Speed up your Vite dev server with SWC", "keywords": [ - "vite", - "vite-plugin", + "fast refresh", "react", - "swc", "react-refresh", - "fast refresh" + "swc", + "vite", + "vite-plugin" ], - "type": "module", - "private": true, - "scripts": { - "dev": "tsdown --watch ./src --watch ../common", - "build": "tsdown", - "test": "playwright test" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" + "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#readme", + "bugs": { + "url": "https://github.com/vitejs/vite-plugin-react/issues" }, + "license": "MIT", + "author": "Arnaud Barré (https://github.com/ArnaudBarre)", "repository": { "type": "git", "url": "git+https://github.com/vitejs/vite-plugin-react.git", "directory": "packages/plugin-react-swc" }, - "bugs": { - "url": "https://github.com/vitejs/vite-plugin-react/issues" + "type": "module", + "scripts": { + "dev": "tsdown --watch ./src --watch ../common", + "build": "tsdown", + "test": "playwright test" }, - "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#readme", "dependencies": { "@rolldown/pluginutils": "1.0.0-beta.58", "@swc/core": "^1.15.8" }, - "peerDependencies": { - "vite": "^4 || ^5 || ^6 || ^7" - }, "devDependencies": { "@playwright/test": "^1.57.0", "@types/fs-extra": "^11.0.4", @@ -47,5 +41,11 @@ "prettier": "^3.0.3", "tsdown": "^0.18.4", "typescript": "^5.9.3" + }, + "peerDependencies": { + "vite": "^4 || ^5 || ^6 || ^7" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" } } diff --git a/packages/plugin-react-swc/playground/base-path/package.json b/packages/plugin-react-swc/playground/base-path/package.json index 3476e7007..a6c3b5b78 100644 --- a/packages/plugin-react-swc/playground/base-path/package.json +++ b/packages/plugin-react-swc/playground/base-path/package.json @@ -1,7 +1,7 @@ { "name": "playground-base-test", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/base-path/vite.config.ts b/packages/plugin-react-swc/playground/base-path/vite.config.ts index 7bc60be8f..867d42f32 100644 --- a/packages/plugin-react-swc/playground/base-path/vite.config.ts +++ b/packages/plugin-react-swc/playground/base-path/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/playground/class-components/package.json b/packages/plugin-react-swc/playground/class-components/package.json index 25a754c33..1622f8ec4 100644 --- a/packages/plugin-react-swc/playground/class-components/package.json +++ b/packages/plugin-react-swc/playground/class-components/package.json @@ -1,7 +1,7 @@ { "name": "class-components", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/class-components/vite.config.ts b/packages/plugin-react-swc/playground/class-components/vite.config.ts index 7af9f6f97..9808d13cf 100644 --- a/packages/plugin-react-swc/playground/class-components/vite.config.ts +++ b/packages/plugin-react-swc/playground/class-components/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/playground/decorators/package.json b/packages/plugin-react-swc/playground/decorators/package.json index b84446747..2ce1fa9a7 100644 --- a/packages/plugin-react-swc/playground/decorators/package.json +++ b/packages/plugin-react-swc/playground/decorators/package.json @@ -1,7 +1,7 @@ { "name": "playground-decorators", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/decorators/vite.config.ts b/packages/plugin-react-swc/playground/decorators/vite.config.ts index a2d1b8860..6a8ef0460 100644 --- a/packages/plugin-react-swc/playground/decorators/vite.config.ts +++ b/packages/plugin-react-swc/playground/decorators/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react({ tsDecorators: true })], diff --git a/packages/plugin-react-swc/playground/emotion-plugin/package.json b/packages/plugin-react-swc/playground/emotion-plugin/package.json index 9cd041dce..1e1233d5b 100644 --- a/packages/plugin-react-swc/playground/emotion-plugin/package.json +++ b/packages/plugin-react-swc/playground/emotion-plugin/package.json @@ -1,7 +1,7 @@ { "name": "playground-emotion-plugin", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/emotion-plugin/src/Button.jsx b/packages/plugin-react-swc/playground/emotion-plugin/src/Button.jsx index 56c363572..ebc90a14e 100644 --- a/packages/plugin-react-swc/playground/emotion-plugin/src/Button.jsx +++ b/packages/plugin-react-swc/playground/emotion-plugin/src/Button.jsx @@ -1,5 +1,5 @@ -import styled from '@emotion/styled' import { css } from '@emotion/react' +import styled from '@emotion/styled' import { useState } from 'react' // Ensure HMR of styled component alongside other components diff --git a/packages/plugin-react-swc/playground/emotion-plugin/vite.config.js b/packages/plugin-react-swc/playground/emotion-plugin/vite.config.js index 98ac529c9..a9376b589 100644 --- a/packages/plugin-react-swc/playground/emotion-plugin/vite.config.js +++ b/packages/plugin-react-swc/playground/emotion-plugin/vite.config.js @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [ diff --git a/packages/plugin-react-swc/playground/emotion/package.json b/packages/plugin-react-swc/playground/emotion/package.json index c05f5a575..2d1f22a51 100644 --- a/packages/plugin-react-swc/playground/emotion/package.json +++ b/packages/plugin-react-swc/playground/emotion/package.json @@ -1,7 +1,7 @@ { "name": "playground-emotion", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/emotion/src/Button.tsx b/packages/plugin-react-swc/playground/emotion/src/Button.tsx index 8bd3ad6e3..98c3318d8 100644 --- a/packages/plugin-react-swc/playground/emotion/src/Button.tsx +++ b/packages/plugin-react-swc/playground/emotion/src/Button.tsx @@ -1,5 +1,5 @@ -import styled from '@emotion/styled' import { css } from '@emotion/react' +import styled from '@emotion/styled' import { useState } from 'react' // Ensure HMR of styled component alongside other components diff --git a/packages/plugin-react-swc/playground/emotion/vite.config.ts b/packages/plugin-react-swc/playground/emotion/vite.config.ts index cfb4c0283..7f1088171 100644 --- a/packages/plugin-react-swc/playground/emotion/vite.config.ts +++ b/packages/plugin-react-swc/playground/emotion/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react({ jsxImportSource: '@emotion/react' })], diff --git a/packages/plugin-react-swc/playground/hmr/package.json b/packages/plugin-react-swc/playground/hmr/package.json index 352f77056..8a06d9239 100644 --- a/packages/plugin-react-swc/playground/hmr/package.json +++ b/packages/plugin-react-swc/playground/hmr/package.json @@ -1,7 +1,7 @@ { "name": "playground-hmr", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/hmr/vite.config.ts b/packages/plugin-react-swc/playground/hmr/vite.config.ts index 7af9f6f97..9808d13cf 100644 --- a/packages/plugin-react-swc/playground/hmr/vite.config.ts +++ b/packages/plugin-react-swc/playground/hmr/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/playground/mdx/package.json b/packages/plugin-react-swc/playground/mdx/package.json index 579dae9fc..21a860c9c 100644 --- a/packages/plugin-react-swc/playground/mdx/package.json +++ b/packages/plugin-react-swc/playground/mdx/package.json @@ -1,7 +1,7 @@ { "name": "playground-mdx", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/mdx/vite.config.ts b/packages/plugin-react-swc/playground/mdx/vite.config.ts index ff4f655ad..b441f3033 100644 --- a/packages/plugin-react-swc/playground/mdx/vite.config.ts +++ b/packages/plugin-react-swc/playground/mdx/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'vite' import mdx from '@mdx-js/rollup' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [mdx(), react()], diff --git a/packages/plugin-react-swc/playground/react-18/package.json b/packages/plugin-react-swc/playground/react-18/package.json index f2fd31476..33c06b9dc 100644 --- a/packages/plugin-react-swc/playground/react-18/package.json +++ b/packages/plugin-react-swc/playground/react-18/package.json @@ -1,7 +1,7 @@ { "name": "playground-react-18", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/react-18/vite.config.ts b/packages/plugin-react-swc/playground/react-18/vite.config.ts index 7af9f6f97..9808d13cf 100644 --- a/packages/plugin-react-swc/playground/react-18/vite.config.ts +++ b/packages/plugin-react-swc/playground/react-18/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/playground/shadow-export/package.json b/packages/plugin-react-swc/playground/shadow-export/package.json index fc30a51b7..f2bb4e819 100644 --- a/packages/plugin-react-swc/playground/shadow-export/package.json +++ b/packages/plugin-react-swc/playground/shadow-export/package.json @@ -1,7 +1,7 @@ { "name": "playground-shadow-export", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/shadow-export/vite.config.ts b/packages/plugin-react-swc/playground/shadow-export/vite.config.ts index 7af9f6f97..9808d13cf 100644 --- a/packages/plugin-react-swc/playground/shadow-export/vite.config.ts +++ b/packages/plugin-react-swc/playground/shadow-export/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/playground/styled-components/package.json b/packages/plugin-react-swc/playground/styled-components/package.json index 51da2a153..6472ef89d 100644 --- a/packages/plugin-react-swc/playground/styled-components/package.json +++ b/packages/plugin-react-swc/playground/styled-components/package.json @@ -1,7 +1,7 @@ { "name": "playground-styled-components", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/styled-components/src/Button.tsx b/packages/plugin-react-swc/playground/styled-components/src/Button.tsx index 44be3f5bf..5a5030867 100644 --- a/packages/plugin-react-swc/playground/styled-components/src/Button.tsx +++ b/packages/plugin-react-swc/playground/styled-components/src/Button.tsx @@ -1,5 +1,5 @@ -import styled, { css } from 'styled-components' import { useState } from 'react' +import styled, { css } from 'styled-components' // Ensure HMR of styled component alongside other components export const StyledCode = styled.code` diff --git a/packages/plugin-react-swc/playground/styled-components/vite.config.ts b/packages/plugin-react-swc/playground/styled-components/vite.config.ts index f852b23ee..c47750bab 100644 --- a/packages/plugin-react-swc/playground/styled-components/vite.config.ts +++ b/packages/plugin-react-swc/playground/styled-components/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react({ plugins: [['@swc/plugin-styled-components', {}]] })], diff --git a/packages/plugin-react-swc/playground/ts-lib/package.json b/packages/plugin-react-swc/playground/ts-lib/package.json index 0f9f68bfc..de534ef45 100644 --- a/packages/plugin-react-swc/playground/ts-lib/package.json +++ b/packages/plugin-react-swc/playground/ts-lib/package.json @@ -1,7 +1,7 @@ { "name": "playground-ts-lib", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/ts-lib/vite.config.ts b/packages/plugin-react-swc/playground/ts-lib/vite.config.ts index 7af9f6f97..9808d13cf 100644 --- a/packages/plugin-react-swc/playground/ts-lib/vite.config.ts +++ b/packages/plugin-react-swc/playground/ts-lib/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/playground/worker/package.json b/packages/plugin-react-swc/playground/worker/package.json index 944227f05..2fe0f2f47 100644 --- a/packages/plugin-react-swc/playground/worker/package.json +++ b/packages/plugin-react-swc/playground/worker/package.json @@ -1,7 +1,7 @@ { "name": "playground-worker", - "type": "module", "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build", diff --git a/packages/plugin-react-swc/playground/worker/vite.config.ts b/packages/plugin-react-swc/playground/worker/vite.config.ts index 7af9f6f97..9808d13cf 100644 --- a/packages/plugin-react-swc/playground/worker/vite.config.ts +++ b/packages/plugin-react-swc/playground/worker/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index ce875d6a5..57918a09b 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -1,6 +1,7 @@ import { readFileSync } from 'node:fs' -import { join } from 'node:path' import { createRequire } from 'node:module' +import { join } from 'node:path' +import { exactRegex } from '@rolldown/pluginutils' import { type JscTarget, type Output, @@ -9,7 +10,6 @@ import { type Options as SWCOptions, transform, } from '@swc/core' -import type { Plugin } from 'vite' import { addRefreshWrapper, getPreambleCode, @@ -17,8 +17,8 @@ import { silenceUseClientWarning, virtualPreamblePlugin, } from '@vitejs/react-common' +import type { Plugin } from 'vite' import * as vite from 'vite' -import { exactRegex } from '@rolldown/pluginutils' const resolve = createRequire(import.meta.url).resolve diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index fca4006d2..e56cd2dbc 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -1,24 +1,33 @@ { "name": "@vitejs/plugin-react", "version": "5.1.2", - "license": "MIT", - "author": "Evan You", "description": "The default Vite plugin for React projects", "keywords": [ - "vite", - "vite-plugin", - "react", "babel", + "fast refresh", + "react", "react-refresh", - "fast refresh" + "vite", + "vite-plugin" ], + "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme", + "bugs": { + "url": "https://github.com/vitejs/vite-plugin-react/issues" + }, + "license": "MIT", + "author": "Evan You", "contributors": [ "Alec Larson", "Arnaud Barré" ], + "repository": { + "type": "git", + "url": "git+https://github.com/vitejs/vite-plugin-react.git", + "directory": "packages/plugin-react" + }, "files": [ - "types", - "dist" + "dist", + "types" ], "type": "module", "exports": { @@ -31,18 +40,6 @@ "prepublishOnly": "npm run build", "test-unit": "vitest run" }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vitejs/vite-plugin-react.git", - "directory": "packages/plugin-react" - }, - "bugs": { - "url": "https://github.com/vitejs/vite-plugin-react/issues" - }, - "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme", "dependencies": { "@babel/core": "^7.28.5", "@babel/plugin-transform-react-jsx-self": "^7.27.1", @@ -51,9 +48,6 @@ "@types/babel__core": "^7.20.5", "react-refresh": "^0.18.0" }, - "peerDependencies": { - "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" - }, "devDependencies": { "@vitejs/react-common": "workspace:*", "babel-plugin-react-compiler": "19.1.0-rc.3", @@ -61,5 +55,11 @@ "react-dom": "^19.2.3", "rolldown": "1.0.0-beta.58", "tsdown": "^0.18.4" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" } } diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 3d9cb3021..6014b457b 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -1,11 +1,12 @@ +import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' -import { readFileSync } from 'node:fs' import type * as babelCore from '@babel/core' import type { ParserOptions, TransformOptions } from '@babel/core' -import { createFilter } from 'vite' -import * as vite from 'vite' -import type { Plugin, ResolvedConfig } from 'vite' +import { + exactRegex, + makeIdFiltersToMatchWithQuery, +} from '@rolldown/pluginutils' import { addRefreshWrapper, getPreambleCode, @@ -14,10 +15,9 @@ import { silenceUseClientWarning, virtualPreamblePlugin, } from '@vitejs/react-common' -import { - exactRegex, - makeIdFiltersToMatchWithQuery, -} from '@rolldown/pluginutils' +import type { Plugin, ResolvedConfig } from 'vite' +import { createFilter } from 'vite' +import * as vite from 'vite' const _dirname = dirname(fileURLToPath(import.meta.url)) const refreshRuntimePath = join(_dirname, 'refresh-runtime.js') diff --git a/packages/plugin-react/tests/rolldown.test.ts b/packages/plugin-react/tests/rolldown.test.ts index e62e7cb53..ab9c0b16d 100644 --- a/packages/plugin-react/tests/rolldown.test.ts +++ b/packages/plugin-react/tests/rolldown.test.ts @@ -1,6 +1,6 @@ import path from 'node:path' -import { expect, test } from 'vitest' import { type Plugin, rolldown } from 'rolldown' +import { expect, test } from 'vitest' import pluginReact, { type Options } from '../src/index.ts' test('HMR related code should not be included when using rolldown', async () => { diff --git a/packages/plugin-rsc/e2e/basic.test.ts b/packages/plugin-rsc/e2e/basic.test.ts index b76a22743..911127641 100644 --- a/packages/plugin-rsc/e2e/basic.test.ts +++ b/packages/plugin-rsc/e2e/basic.test.ts @@ -1,11 +1,14 @@ import { createHash } from 'node:crypto' import { readFileSync } from 'node:fs' +import path from 'node:path' import { type Page, type Response as PlaywrightResponse, expect, test, } from '@playwright/test' +import { x } from 'tinyexec' +import { normalizePath, type Rollup } from 'vite' import { type Fixture, useCreateEditor, useFixture } from './fixture' import { expectNoPageError, @@ -13,9 +16,6 @@ import { testNoJs, waitForHydration, } from './helper' -import { x } from 'tinyexec' -import { normalizePath, type Rollup } from 'vite' -import path from 'node:path' test.describe('dev-default', () => { const f = useFixture({ root: 'examples/basic', mode: 'dev' }) diff --git a/packages/plugin-rsc/e2e/browser.test.ts b/packages/plugin-rsc/e2e/browser.test.ts index 3b5898047..203bd05d4 100644 --- a/packages/plugin-rsc/e2e/browser.test.ts +++ b/packages/plugin-rsc/e2e/browser.test.ts @@ -1,8 +1,8 @@ +import fs from 'node:fs' +import path from 'node:path' import { expect, test } from '@playwright/test' import { useFixture } from './fixture' import { defineStarterTest } from './starter' -import path from 'node:path' -import fs from 'node:fs' // Webkit fails by // > TypeError: ReadableByteStreamController is not implemented diff --git a/packages/plugin-rsc/e2e/build-app.test.ts b/packages/plugin-rsc/e2e/build-app.test.ts index cf23ca6c0..dc53a2705 100644 --- a/packages/plugin-rsc/e2e/build-app.test.ts +++ b/packages/plugin-rsc/e2e/build-app.test.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test' -import { setupInlineFixture, useFixture } from './fixture' import { x } from 'tinyexec' +import { setupInlineFixture, useFixture } from './fixture' import { waitForHydration } from './helper' test.describe('buildApp hook', () => { diff --git a/packages/plugin-rsc/e2e/error.test.ts b/packages/plugin-rsc/e2e/error.test.ts index ea2b63b11..a86ccbbab 100644 --- a/packages/plugin-rsc/e2e/error.test.ts +++ b/packages/plugin-rsc/e2e/error.test.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test' -import { setupInlineFixture } from './fixture' import { x } from 'tinyexec' +import { setupInlineFixture } from './fixture' test.describe('invalid directives', () => { test.describe('"use server" in "use client"', () => { diff --git a/packages/plugin-rsc/e2e/isolated.test.ts b/packages/plugin-rsc/e2e/isolated.test.ts index d67a91be4..dd1a41f7e 100644 --- a/packages/plugin-rsc/e2e/isolated.test.ts +++ b/packages/plugin-rsc/e2e/isolated.test.ts @@ -1,11 +1,11 @@ -import { expect, test, type Page } from '@playwright/test' -import { setupIsolatedFixture, useFixture } from './fixture' -import { defineStarterTest } from './starter' -import path from 'node:path' import os from 'node:os' +import path from 'node:path' +import { expect, test, type Page } from '@playwright/test' +import { x } from 'tinyexec' import * as vite from 'vite' +import { setupIsolatedFixture, useFixture } from './fixture' import { waitForHydration } from './helper' -import { x } from 'tinyexec' +import { defineStarterTest } from './starter' test.describe(() => { // use RUNNER_TEMP on Github Actions diff --git a/packages/plugin-rsc/e2e/no-ssr.test.ts b/packages/plugin-rsc/e2e/no-ssr.test.ts index 16e814162..32ba183de 100644 --- a/packages/plugin-rsc/e2e/no-ssr.test.ts +++ b/packages/plugin-rsc/e2e/no-ssr.test.ts @@ -1,8 +1,8 @@ +import fs from 'node:fs' +import path from 'node:path' import { expect, test } from '@playwright/test' import { useFixture } from './fixture' import { defineStarterTest } from './starter' -import path from 'node:path' -import fs from 'node:fs' test.describe('dev-no-ssr', () => { const f = useFixture({ root: 'examples/no-ssr', mode: 'dev' }) diff --git a/packages/plugin-rsc/e2e/react-compiler.test.ts b/packages/plugin-rsc/e2e/react-compiler.test.ts index 2c36e24b5..894f83206 100644 --- a/packages/plugin-rsc/e2e/react-compiler.test.ts +++ b/packages/plugin-rsc/e2e/react-compiler.test.ts @@ -1,7 +1,7 @@ import { expect, test } from '@playwright/test' import { setupInlineFixture, useFixture } from './fixture' -import { defineStarterTest } from './starter' import { waitForHydration } from './helper' +import { defineStarterTest } from './starter' test.describe(() => { const root = 'examples/e2e/temp/react-compiler' diff --git a/packages/plugin-rsc/e2e/react-router.test.ts b/packages/plugin-rsc/e2e/react-router.test.ts index 0807e2aaf..bcfe8ae9b 100644 --- a/packages/plugin-rsc/e2e/react-router.test.ts +++ b/packages/plugin-rsc/e2e/react-router.test.ts @@ -1,9 +1,9 @@ import { createHash } from 'node:crypto' +import { readFileSync } from 'node:fs' import { expect, test } from '@playwright/test' +import React from 'react' import { type Fixture, useFixture } from './fixture' import { expectNoReload, testNoJs, waitForHydration } from './helper' -import { readFileSync } from 'node:fs' -import React from 'react' test.describe('dev-default', () => { test.skip(/canary|experimental/.test(React.version)) diff --git a/packages/plugin-rsc/e2e/render-built-url.test.ts b/packages/plugin-rsc/e2e/render-built-url.test.ts index e9e70e6d6..164ba3215 100644 --- a/packages/plugin-rsc/e2e/render-built-url.test.ts +++ b/packages/plugin-rsc/e2e/render-built-url.test.ts @@ -1,9 +1,9 @@ +import fs from 'node:fs' import { expect, test } from '@playwright/test' +import type { RenderBuiltAssetUrl } from 'vite' import { setupInlineFixture, useFixture } from './fixture' -import { defineStarterTest } from './starter' import { expectNoPageError, waitForHydration } from './helper' -import fs from 'node:fs' -import type { RenderBuiltAssetUrl } from 'vite' +import { defineStarterTest } from './starter' test.describe(() => { const root = 'examples/e2e/temp/renderBuiltUrl-runtime' diff --git a/packages/plugin-rsc/e2e/root.test.ts b/packages/plugin-rsc/e2e/root.test.ts index ae59a95de..5ff9cbc74 100644 --- a/packages/plugin-rsc/e2e/root.test.ts +++ b/packages/plugin-rsc/e2e/root.test.ts @@ -1,8 +1,8 @@ +import fs from 'node:fs' +import path from 'node:path' import { test } from '@playwright/test' import { setupInlineFixture, useFixture } from './fixture' import { defineStarterTest } from './starter' -import fs from 'node:fs' -import path from 'node:path' test.describe(() => { const root = 'examples/e2e/temp/root' diff --git a/packages/plugin-rsc/e2e/starter.test.ts b/packages/plugin-rsc/e2e/starter.test.ts index 403f4f923..f022d390c 100644 --- a/packages/plugin-rsc/e2e/starter.test.ts +++ b/packages/plugin-rsc/e2e/starter.test.ts @@ -1,8 +1,8 @@ import { expect, test } from '@playwright/test' +import { x } from 'tinyexec' import { setupInlineFixture, useFixture, type Fixture } from './fixture' -import { defineStarterTest } from './starter' import { expectNoPageError, waitForHydration } from './helper' -import { x } from 'tinyexec' +import { defineStarterTest } from './starter' test.describe('dev-default', () => { const f = useFixture({ root: 'examples/starter', mode: 'dev' }) diff --git a/packages/plugin-rsc/e2e/validate-imports.test.ts b/packages/plugin-rsc/e2e/validate-imports.test.ts index e87bcb536..6224bf497 100644 --- a/packages/plugin-rsc/e2e/validate-imports.test.ts +++ b/packages/plugin-rsc/e2e/validate-imports.test.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test' -import { setupInlineFixture, useFixture, type Fixture } from './fixture' import { x } from 'tinyexec' +import { setupInlineFixture, useFixture, type Fixture } from './fixture' import { expectNoPageError, waitForHydration } from './helper' test.describe('validate imports', () => { diff --git a/packages/plugin-rsc/examples/basic/src/framework/entry.browser.tsx b/packages/plugin-rsc/examples/basic/src/framework/entry.browser.tsx index bbf3a5ddb..bbbc66949 100644 --- a/packages/plugin-rsc/examples/basic/src/framework/entry.browser.tsx +++ b/packages/plugin-rsc/examples/basic/src/framework/entry.browser.tsx @@ -8,8 +8,8 @@ import { import React from 'react' import { createRoot, hydrateRoot } from 'react-dom/client' import { rscStream } from 'rsc-html-stream/client' -import { GlobalErrorBoundary } from './error-boundary' import type { RscPayload } from './entry.rsc' +import { GlobalErrorBoundary } from './error-boundary' import { createRscRenderRequest } from './request' async function main() { diff --git a/packages/plugin-rsc/examples/basic/src/framework/entry.rsc.tsx b/packages/plugin-rsc/examples/basic/src/framework/entry.rsc.tsx index aacf13c9c..6872d89d1 100644 --- a/packages/plugin-rsc/examples/basic/src/framework/entry.rsc.tsx +++ b/packages/plugin-rsc/examples/basic/src/framework/entry.rsc.tsx @@ -6,8 +6,8 @@ import { decodeAction, decodeFormState, } from '@vitejs/plugin-rsc/rsc' -import type { ReactFormState } from 'react-dom/client' import type React from 'react' +import type { ReactFormState } from 'react-dom/client' import { parseRenderRequest } from './request.tsx' import '../styles.css' diff --git a/packages/plugin-rsc/examples/basic/src/routes/css-queries/client.tsx b/packages/plugin-rsc/examples/basic/src/routes/css-queries/client.tsx index 682e3ebca..57686ac5f 100644 --- a/packages/plugin-rsc/examples/basic/src/routes/css-queries/client.tsx +++ b/packages/plugin-rsc/examples/basic/src/routes/css-queries/client.tsx @@ -1,9 +1,9 @@ 'use client' -import cssUrl from './client-url.css?url' +import React from 'react' import cssInline from './client-inline.css?inline' import cssRaw from './client-raw.css?raw' -import React from 'react' +import cssUrl from './client-url.css?url' export function TestCssQueriesClient(props: { serverUrl: string diff --git a/packages/plugin-rsc/examples/basic/src/routes/css-queries/server.tsx b/packages/plugin-rsc/examples/basic/src/routes/css-queries/server.tsx index 49ed52ee1..1c6f1dce9 100644 --- a/packages/plugin-rsc/examples/basic/src/routes/css-queries/server.tsx +++ b/packages/plugin-rsc/examples/basic/src/routes/css-queries/server.tsx @@ -1,7 +1,7 @@ -import cssUrl from './server-url.css?url' +import { TestCssQueriesClient } from './client' import cssInline from './server-inline.css?inline' import cssRaw from './server-raw.css?raw' -import { TestCssQueriesClient } from './client' +import cssUrl from './server-url.css?url' export function TestCssQueries() { return ( diff --git a/packages/plugin-rsc/examples/basic/src/routes/root.tsx b/packages/plugin-rsc/examples/basic/src/routes/root.tsx index 2200c2762..715c5d5d8 100644 --- a/packages/plugin-rsc/examples/basic/src/routes/root.tsx +++ b/packages/plugin-rsc/examples/basic/src/routes/root.tsx @@ -1,3 +1,4 @@ +import TestDepCssInServer from '@vitejs/test-dep-css-in-server/server' import React from 'react' import { TestServerActionBindAction, @@ -12,42 +13,41 @@ import { } from './action-from-client/client' import { TestActionStateServer } from './action-state/server' import { ServerCounter } from './action/server' +import { TestAssetsServer } from './assets/server' +import { TestBrowserOnly } from './browser-only/client' +import { TestClientChunkServer } from './chunk/server' +import { TestChunk2 } from './chunk2/server' import { ClientCounter, Hydrated } from './client' +import { TestClientError } from './client-error/client' +import { TestCssQueries } from './css-queries/server' import { TestClientInServer } from './deps/client-in-server/server' import { TestServerInClient } from './deps/server-in-client/client' import { TestServerInServer } from './deps/server-in-server/server' +import { TestTransitiveCjsClient } from './deps/transitive-cjs/client' import { TestHmrClientDep } from './hmr-client-dep/client' +import { TestHmrClientDep2 } from './hmr-client-dep2/client' +import { TestHmrClientDep3 } from './hmr-client-dep3/server' +import { TestHmrSharedAtomic } from './hmr-shared/atomic/server' +import { TestHmrSharedClient } from './hmr-shared/client' +import { TestHmrSharedServer } from './hmr-shared/server' +import { TestHmrSwitchClient } from './hmr-switch/client' +import { TestHmrSwitchServer } from './hmr-switch/server' +import { TestHydrationMismatch } from './hydration-mismatch/server' +import { TestImportMetaGlob } from './import-meta-glob/server' import { TestModuleInvalidationServer } from './module-invalidation/server' import { TestPayloadServer } from './payload/server' +import { TestReactCache } from './react-cache/server' import { TestSerializationServer } from './serialization/server' +import { TestServerError } from './server-error/server' import { TestCssClientNoSsr } from './style-client-no-ssr/server' import { TestStyleClient } from './style-client/client' import { TestStyleServer } from './style-server/server' +import { TestTailwind } from './tailwind' import { TestTemporaryReference } from './temporary-reference/client' -import { TestUseCache } from './use-cache/server' -import { TestReactCache } from './react-cache/server' -import { TestHydrationMismatch } from './hydration-mismatch/server' -import { TestBrowserOnly } from './browser-only/client' -import { TestTransitiveCjsClient } from './deps/transitive-cjs/client' -import TestDepCssInServer from '@vitejs/test-dep-css-in-server/server' -import { TestHmrSharedServer } from './hmr-shared/server' -import { TestHmrSharedClient } from './hmr-shared/client' -import { TestHmrSharedAtomic } from './hmr-shared/atomic/server' -import { TestCssQueries } from './css-queries/server' -import { TestImportMetaGlob } from './import-meta-glob/server' -import { TestAssetsServer } from './assets/server' -import { TestHmrSwitchServer } from './hmr-switch/server' -import { TestHmrSwitchClient } from './hmr-switch/client' import { TestTreeShakeServer } from './tree-shake/server' import { TestTreeShake2 } from './tree-shake2/server' -import { TestClientChunkServer } from './chunk/server' -import { TestTailwind } from './tailwind' -import { TestHmrClientDep2 } from './hmr-client-dep2/client' -import { TestHmrClientDep3 } from './hmr-client-dep3/server' -import { TestChunk2 } from './chunk2/server' +import { TestUseCache } from './use-cache/server' import { TestUseId } from './use-id/server' -import { TestClientError } from './client-error/client' -import { TestServerError } from './server-error/server' export function Root(props: { url: URL }) { return ( diff --git a/packages/plugin-rsc/examples/basic/src/routes/style-client/client.tsx b/packages/plugin-rsc/examples/basic/src/routes/style-client/client.tsx index 53a7c1289..56de4a5e2 100644 --- a/packages/plugin-rsc/examples/basic/src/routes/style-client/client.tsx +++ b/packages/plugin-rsc/examples/basic/src/routes/style-client/client.tsx @@ -2,8 +2,8 @@ import './client.css' import { TestClientDep } from './client-dep' -import styles from './client.module.css' import styleUrl from './client-url.css?url' +import styles from './client.module.css' export function TestStyleClient() { return ( diff --git a/packages/plugin-rsc/examples/basic/src/routes/style-server/server.tsx b/packages/plugin-rsc/examples/basic/src/routes/style-server/server.tsx index a7132153c..02ecfaaac 100644 --- a/packages/plugin-rsc/examples/basic/src/routes/style-server/server.tsx +++ b/packages/plugin-rsc/examples/basic/src/routes/style-server/server.tsx @@ -1,6 +1,6 @@ import './server.css' -import styles from './server.module.css' import styleUrl from './server-url.css?url' +import styles from './server.module.css' export function TestStyleServer() { return ( diff --git a/packages/plugin-rsc/examples/basic/vite.config.ts b/packages/plugin-rsc/examples/basic/vite.config.ts index 79db2e536..eafc96002 100644 --- a/packages/plugin-rsc/examples/basic/vite.config.ts +++ b/packages/plugin-rsc/examples/basic/vite.config.ts @@ -1,8 +1,11 @@ import assert from 'node:assert' -import rsc from '@vitejs/plugin-rsc' -import { transformHoistInlineDirective } from '@vitejs/plugin-rsc/transforms' +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import tailwindcss from '@tailwindcss/vite' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' +import { transformHoistInlineDirective } from '@vitejs/plugin-rsc/transforms' import { type Plugin, type Rollup, @@ -10,9 +13,6 @@ import { normalizePath, parseAstAsync, } from 'vite' -import path from 'node:path' -import fs from 'node:fs' -import { fileURLToPath } from 'node:url' export default defineConfig({ clearScreen: false, diff --git a/packages/plugin-rsc/examples/browser-mode/src/framework/entry.browser.tsx b/packages/plugin-rsc/examples/browser-mode/src/framework/entry.browser.tsx index 336bfa3f6..eed0ec957 100644 --- a/packages/plugin-rsc/examples/browser-mode/src/framework/entry.browser.tsx +++ b/packages/plugin-rsc/examples/browser-mode/src/framework/entry.browser.tsx @@ -1,5 +1,3 @@ -import * as React from 'react' -import { createRoot } from 'react-dom/client' import { createFromFetch, setRequireModule, @@ -7,8 +5,10 @@ import { createTemporaryReferenceSet, encodeReply, } from '@vitejs/plugin-rsc/react/browser' -import type { RscPayload } from './entry.rsc' +import * as React from 'react' +import { createRoot } from 'react-dom/client' import buildClientReferences from 'virtual:vite-rsc-browser-mode/build-client-references' +import type { RscPayload } from './entry.rsc' let fetchServer: typeof import('./entry.rsc').fetchServer diff --git a/packages/plugin-rsc/examples/browser-mode/src/framework/entry.rsc.tsx b/packages/plugin-rsc/examples/browser-mode/src/framework/entry.rsc.tsx index 8129e97d8..e897e14e1 100644 --- a/packages/plugin-rsc/examples/browser-mode/src/framework/entry.rsc.tsx +++ b/packages/plugin-rsc/examples/browser-mode/src/framework/entry.rsc.tsx @@ -8,9 +8,9 @@ import { decodeFormState, } from '@vitejs/plugin-rsc/react/rsc' import type React from 'react' -import { Root } from '../root' import type { ReactFormState } from 'react-dom/client' import buildServerReferences from 'virtual:vite-rsc-browser-mode/build-server-references' +import { Root } from '../root' export type RscPayload = { root: React.ReactNode diff --git a/packages/plugin-rsc/examples/browser-mode/src/framework/load-client-dev.tsx b/packages/plugin-rsc/examples/browser-mode/src/framework/load-client-dev.tsx index 196d6e875..666479752 100644 --- a/packages/plugin-rsc/examples/browser-mode/src/framework/load-client-dev.tsx +++ b/packages/plugin-rsc/examples/browser-mode/src/framework/load-client-dev.tsx @@ -1,5 +1,5 @@ -import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' import { createRPCClient } from 'vite-dev-rpc' +import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' const rpcClient = createRPCClient<{ invoke: Function }, {}>( 'transport-proxy', diff --git a/packages/plugin-rsc/examples/browser-mode/src/framework/main.tsx b/packages/plugin-rsc/examples/browser-mode/src/framework/main.tsx index 6a485deb4..3fd2c6e42 100644 --- a/packages/plugin-rsc/examples/browser-mode/src/framework/main.tsx +++ b/packages/plugin-rsc/examples/browser-mode/src/framework/main.tsx @@ -1,5 +1,5 @@ -import * as server from './entry.rsc' import loadClient from 'virtual:vite-rsc-browser-mode/load-client' +import * as server from './entry.rsc' async function main() { const client = await loadClient() diff --git a/packages/plugin-rsc/examples/browser-mode/src/root.tsx b/packages/plugin-rsc/examples/browser-mode/src/root.tsx index e8d912527..6d5857bc6 100644 --- a/packages/plugin-rsc/examples/browser-mode/src/root.tsx +++ b/packages/plugin-rsc/examples/browser-mode/src/root.tsx @@ -1,10 +1,10 @@ import './index.css' import viteLogo from '/vite.svg' +import { TestActionBind } from './action-bind/server.tsx' +import { TestUseActionState } from './action-from-client/client.tsx' import { getServerCounter, updateServerCounter } from './action.tsx' import reactLogo from './assets/react.svg' import { ClientCounter } from './client.tsx' -import { TestUseActionState } from './action-from-client/client.tsx' -import { TestActionBind } from './action-bind/server.tsx' export function Root() { return diff --git a/packages/plugin-rsc/examples/browser-mode/vite.config.ts b/packages/plugin-rsc/examples/browser-mode/vite.config.ts index 2a1f9de8f..8d8062321 100644 --- a/packages/plugin-rsc/examples/browser-mode/vite.config.ts +++ b/packages/plugin-rsc/examples/browser-mode/vite.config.ts @@ -1,9 +1,9 @@ -import { defaultClientConditions, defineConfig, type Plugin } from 'vite' import { vitePluginRscMinimal, getPluginApi, type PluginApi, } from '@vitejs/plugin-rsc/plugin' +import { defaultClientConditions, defineConfig, type Plugin } from 'vite' import { createRPCServer } from 'vite-dev-rpc' export default defineConfig({ diff --git a/packages/plugin-rsc/examples/browser/lib/dev-proxy.ts b/packages/plugin-rsc/examples/browser/lib/dev-proxy.ts index 688b361ee..a01428062 100644 --- a/packages/plugin-rsc/examples/browser/lib/dev-proxy.ts +++ b/packages/plugin-rsc/examples/browser/lib/dev-proxy.ts @@ -1,5 +1,5 @@ -import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' import { createRPCClient } from 'vite-dev-rpc' +import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' const rpcClient = createRPCClient<{ invoke: Function }, {}>( 'rsc:transport-proxy', diff --git a/packages/plugin-rsc/examples/browser/src/framework/entry.browser.tsx b/packages/plugin-rsc/examples/browser/src/framework/entry.browser.tsx index 8a7147594..3858a2105 100644 --- a/packages/plugin-rsc/examples/browser/src/framework/entry.browser.tsx +++ b/packages/plugin-rsc/examples/browser/src/framework/entry.browser.tsx @@ -1,13 +1,13 @@ -import React from 'react' -import { createRoot } from 'react-dom/client' import { createFromFetch, setServerCallback, createTemporaryReferenceSet, encodeReply, } from '@vitejs/plugin-rsc/browser' -import type { RscPayload } from './entry.rsc' +import React from 'react' +import { createRoot } from 'react-dom/client' import { loadEntryRsc } from '../../lib/runtime' +import type { RscPayload } from './entry.rsc' async function fetchRsc(request: Request): Promise { const module = await loadEntryRsc() diff --git a/packages/plugin-rsc/examples/browser/vite.config.ts b/packages/plugin-rsc/examples/browser/vite.config.ts index 47e029848..c0485cf59 100644 --- a/packages/plugin-rsc/examples/browser/vite.config.ts +++ b/packages/plugin-rsc/examples/browser/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import rsc from '@vitejs/plugin-rsc' +import { defineConfig } from 'vite' import rscBrowser from './lib/plugin' export default defineConfig({ diff --git a/packages/plugin-rsc/examples/e2e/middleware-mode.ts b/packages/plugin-rsc/examples/e2e/middleware-mode.ts index edde15bbe..6859ea1bd 100644 --- a/packages/plugin-rsc/examples/e2e/middleware-mode.ts +++ b/packages/plugin-rsc/examples/e2e/middleware-mode.ts @@ -2,8 +2,8 @@ import path from 'node:path' import { pathToFileURL } from 'node:url' // @ts-ignore import connect from 'connect' -import { toNodeHandler } from 'srvx/node' import sirv from 'sirv' +import { toNodeHandler } from 'srvx/node' import type { Connect } from 'vite' async function main() { diff --git a/packages/plugin-rsc/examples/no-ssr/vite.config.ts b/packages/plugin-rsc/examples/no-ssr/vite.config.ts index ce349c6e9..87a8b8c87 100644 --- a/packages/plugin-rsc/examples/no-ssr/vite.config.ts +++ b/packages/plugin-rsc/examples/no-ssr/vite.config.ts @@ -1,7 +1,7 @@ -import rsc from '@vitejs/plugin-rsc' +import fsp from 'node:fs/promises' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' import { defineConfig, type Plugin } from 'vite' -import fsp from 'node:fs/promises' export default defineConfig({ plugins: [ diff --git a/packages/plugin-rsc/examples/react-router/cf/vite.config.ts b/packages/plugin-rsc/examples/react-router/cf/vite.config.ts index 96b91e749..27ebb6b76 100644 --- a/packages/plugin-rsc/examples/react-router/cf/vite.config.ts +++ b/packages/plugin-rsc/examples/react-router/cf/vite.config.ts @@ -1,7 +1,7 @@ import { cloudflare } from '@cloudflare/vite-plugin' -import rsc from '@vitejs/plugin-rsc' import tailwindcss from '@tailwindcss/vite' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' import { defineConfig } from 'vite' export default defineConfig({ diff --git a/packages/plugin-rsc/examples/react-router/vite.config.ts b/packages/plugin-rsc/examples/react-router/vite.config.ts index 4bea05c1b..0746928d7 100644 --- a/packages/plugin-rsc/examples/react-router/vite.config.ts +++ b/packages/plugin-rsc/examples/react-router/vite.config.ts @@ -1,6 +1,6 @@ -import rsc from '@vitejs/plugin-rsc' import tailwindcss from '@tailwindcss/vite' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' import { defineConfig } from 'vite' export default defineConfig({ diff --git a/packages/plugin-rsc/examples/ssg/vite.config.ts b/packages/plugin-rsc/examples/ssg/vite.config.ts index abb2fcc73..94396bdfb 100644 --- a/packages/plugin-rsc/examples/ssg/vite.config.ts +++ b/packages/plugin-rsc/examples/ssg/vite.config.ts @@ -2,9 +2,9 @@ import fs from 'node:fs' import path from 'node:path' import { Readable } from 'node:stream' import { pathToFileURL } from 'node:url' -import rsc from '@vitejs/plugin-rsc' import mdx from '@mdx-js/rollup' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' import { type Plugin, type ResolvedConfig, defineConfig } from 'vite' const RSC_POSTFIX = '_.rsc' diff --git a/packages/plugin-rsc/examples/starter-cf-single/src/framework/entry.browser.tsx b/packages/plugin-rsc/examples/starter-cf-single/src/framework/entry.browser.tsx index c3a9155e1..5b48ebdfa 100644 --- a/packages/plugin-rsc/examples/starter-cf-single/src/framework/entry.browser.tsx +++ b/packages/plugin-rsc/examples/starter-cf-single/src/framework/entry.browser.tsx @@ -8,8 +8,8 @@ import { import React from 'react' import { createRoot, hydrateRoot } from 'react-dom/client' import { rscStream } from 'rsc-html-stream/client' -import { GlobalErrorBoundary } from './error-boundary' import type { RscPayload } from './entry.rsc' +import { GlobalErrorBoundary } from './error-boundary' import { createRscRenderRequest } from './request' async function main() { diff --git a/packages/plugin-rsc/examples/starter-cf-single/vite.config.ts b/packages/plugin-rsc/examples/starter-cf-single/vite.config.ts index e93d3b493..adef8cab5 100644 --- a/packages/plugin-rsc/examples/starter-cf-single/vite.config.ts +++ b/packages/plugin-rsc/examples/starter-cf-single/vite.config.ts @@ -1,6 +1,6 @@ import { cloudflare } from '@cloudflare/vite-plugin' -import rsc from '@vitejs/plugin-rsc' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' import { defineConfig } from 'vite' export default defineConfig({ diff --git a/packages/plugin-rsc/examples/starter/src/framework/entry.browser.tsx b/packages/plugin-rsc/examples/starter/src/framework/entry.browser.tsx index c3a9155e1..5b48ebdfa 100644 --- a/packages/plugin-rsc/examples/starter/src/framework/entry.browser.tsx +++ b/packages/plugin-rsc/examples/starter/src/framework/entry.browser.tsx @@ -8,8 +8,8 @@ import { import React from 'react' import { createRoot, hydrateRoot } from 'react-dom/client' import { rscStream } from 'rsc-html-stream/client' -import { GlobalErrorBoundary } from './error-boundary' import type { RscPayload } from './entry.rsc' +import { GlobalErrorBoundary } from './error-boundary' import { createRscRenderRequest } from './request' async function main() { diff --git a/packages/plugin-rsc/examples/starter/vite.config.ts b/packages/plugin-rsc/examples/starter/vite.config.ts index 6319f33f6..9b9c9e014 100644 --- a/packages/plugin-rsc/examples/starter/vite.config.ts +++ b/packages/plugin-rsc/examples/starter/vite.config.ts @@ -1,5 +1,5 @@ -import rsc from '@vitejs/plugin-rsc' import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' import { defineConfig } from 'vite' export default defineConfig({ diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index 51c7d27ee..defae9468 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -3,19 +3,23 @@ "version": "0.5.11", "description": "React Server Components (RSC) support for Vite.", "keywords": [ - "vite", - "vite-plugin", "react", "react-server-components", - "rsc" + "rsc", + "vite", + "vite-plugin" ], "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc", + "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/vitejs/vite-plugin-react.git", "directory": "packages/plugin-rsc" }, - "license": "MIT", + "files": [ + "dist", + "types" + ], "type": "module", "exports": { "./package.json": "./package.json", @@ -24,10 +28,6 @@ "./transforms": "./dist/transforms/index.js", "./*": "./dist/*.js" }, - "files": [ - "dist", - "types" - ], "scripts": { "test": "vitest", "test-e2e": "playwright test --project=chromium", diff --git a/packages/plugin-rsc/src/plugin.ts b/packages/plugin-rsc/src/plugin.ts index 3eda2931a..bf7202e98 100644 --- a/packages/plugin-rsc/src/plugin.ts +++ b/packages/plugin-rsc/src/plugin.ts @@ -3,9 +3,11 @@ import fs from 'node:fs' import { createRequire } from 'node:module' import path from 'node:path' import { pathToFileURL } from 'node:url' -import { toNodeHandler } from 'srvx/node' +import { createDebug } from '@hiogawa/utils' import * as esModuleLexer from 'es-module-lexer' import MagicString from 'magic-string' +import { toNodeHandler } from 'srvx/node' +import { stripLiteral } from 'strip-literal' import * as vite from 'vite' import { type BuilderOptions, @@ -23,24 +25,15 @@ import { } from 'vite' import { crawlFrameworkPkgs } from 'vitefu' import vitePluginRscCore from './core/plugin' -import { - type TransformWrapExportFilter, - hasDirective, - transformDirectiveProxyExport, - transformServerActionServer, - transformWrapExport, - findDirectives, -} from './transforms' -import { generateEncryptionKey, toBase64 } from './utils/encryption-utils' -import { createRpcServer } from './utils/rpc' -import { - cleanUrl, - directRequestRE, - evalValue, - normalizeViteImportAnalysisUrl, - prepareError, -} from './plugins/vite-utils' import { cjsModuleRunnerPlugin } from './plugins/cjs' +import { vitePluginFindSourceMapURL } from './plugins/find-source-map-url' +import { scanBuildStripPlugin } from './plugins/scan' +import { + parseCssVirtual, + toCssVirtual, + parseIdQuery, + parseReferenceValidationVirtual, +} from './plugins/shared' import { createVirtualPlugin, getEntrySource, @@ -51,17 +44,24 @@ import { withRollupError, getFallbackRollupEntry, } from './plugins/utils' -import { createDebug } from '@hiogawa/utils' -import { scanBuildStripPlugin } from './plugins/scan' import { validateImportPlugin } from './plugins/validate-import' -import { vitePluginFindSourceMapURL } from './plugins/find-source-map-url' import { - parseCssVirtual, - toCssVirtual, - parseIdQuery, - parseReferenceValidationVirtual, -} from './plugins/shared' -import { stripLiteral } from 'strip-literal' + cleanUrl, + directRequestRE, + evalValue, + normalizeViteImportAnalysisUrl, + prepareError, +} from './plugins/vite-utils' +import { + type TransformWrapExportFilter, + hasDirective, + transformDirectiveProxyExport, + transformServerActionServer, + transformWrapExport, + findDirectives, +} from './transforms' +import { generateEncryptionKey, toBase64 } from './utils/encryption-utils' +import { createRpcServer } from './utils/rpc' const isRolldownVite = 'rolldownVersion' in vite diff --git a/packages/plugin-rsc/src/plugins/cjs.ts b/packages/plugin-rsc/src/plugins/cjs.ts index 73315615a..97378f479 100644 --- a/packages/plugin-rsc/src/plugins/cjs.ts +++ b/packages/plugin-rsc/src/plugins/cjs.ts @@ -1,10 +1,10 @@ -import { parseAstAsync, type Plugin } from 'vite' -import { findClosestPkgJsonPath } from 'vitefu' -import path from 'node:path' import fs from 'node:fs' +import path from 'node:path' +import { createDebug } from '@hiogawa/utils' import * as esModuleLexer from 'es-module-lexer' +import { parseAstAsync, type Plugin } from 'vite' +import { findClosestPkgJsonPath } from 'vitefu' import { transformCjsToEsm } from '../transforms/cjs' -import { createDebug } from '@hiogawa/utils' import { parseIdQuery } from './shared' const debug = createDebug('vite-rsc:cjs') diff --git a/packages/plugin-rsc/src/plugins/find-source-map-url.ts b/packages/plugin-rsc/src/plugins/find-source-map-url.ts index dbe2d84ca..4f84bc63c 100644 --- a/packages/plugin-rsc/src/plugins/find-source-map-url.ts +++ b/packages/plugin-rsc/src/plugins/find-source-map-url.ts @@ -1,3 +1,4 @@ +import fs from 'node:fs' import { fileURLToPath } from 'node:url' import { isFileLoadingAllowed, @@ -5,7 +6,6 @@ import { type Plugin, type ViteDevServer, } from 'vite' -import fs from 'node:fs' import { slash } from './vite-utils' // diff --git a/packages/plugin-rsc/src/plugins/scan.test.ts b/packages/plugin-rsc/src/plugins/scan.test.ts index aa3447ff4..e1715a9e8 100644 --- a/packages/plugin-rsc/src/plugins/scan.test.ts +++ b/packages/plugin-rsc/src/plugins/scan.test.ts @@ -1,5 +1,5 @@ -import { beforeAll, describe, expect, it } from 'vitest' import * as esModuleLexer from 'es-module-lexer' +import { beforeAll, describe, expect, it } from 'vitest' import { transformScanBuildStrip } from './scan' describe(transformScanBuildStrip, () => { diff --git a/packages/plugin-rsc/src/plugins/scan.ts b/packages/plugin-rsc/src/plugins/scan.ts index be1a60a1e..e72552663 100644 --- a/packages/plugin-rsc/src/plugins/scan.ts +++ b/packages/plugin-rsc/src/plugins/scan.ts @@ -1,6 +1,6 @@ import * as esModuleLexer from 'es-module-lexer' -import { parseAstAsync, type Plugin } from 'vite' import { walk } from 'estree-walker' +import { parseAstAsync, type Plugin } from 'vite' import type { RscPluginManager } from '../plugin' // During scan build, we strip all code but imports to diff --git a/packages/plugin-rsc/src/plugins/vite-utils.ts b/packages/plugin-rsc/src/plugins/vite-utils.ts index afa780b11..511785658 100644 --- a/packages/plugin-rsc/src/plugins/vite-utils.ts +++ b/packages/plugin-rsc/src/plugins/vite-utils.ts @@ -2,8 +2,8 @@ import fs from 'node:fs' import path from 'node:path' -import type { DevEnvironment, ErrorPayload, Rollup } from 'vite' import { stripVTControlCharacters as strip } from 'node:util' +import type { DevEnvironment, ErrorPayload, Rollup } from 'vite' export const VALID_ID_PREFIX = `/@id/` diff --git a/packages/plugin-rsc/src/ssr.tsx b/packages/plugin-rsc/src/ssr.tsx index 6f71fa67f..752a1a51f 100644 --- a/packages/plugin-rsc/src/ssr.tsx +++ b/packages/plugin-rsc/src/ssr.tsx @@ -1,6 +1,6 @@ +import * as ReactDOM from 'react-dom' import assetsManifest from 'virtual:vite-rsc/assets-manifest' import * as clientReferences from 'virtual:vite-rsc/client-references' -import * as ReactDOM from 'react-dom' import { setRequireModule } from './core/ssr' import type { ResolvedAssetDeps } from './plugin' import { toCssVirtual, toReferenceValidationVirtual } from './plugins/shared' diff --git a/packages/plugin-rsc/src/transforms/cjs.test.ts b/packages/plugin-rsc/src/transforms/cjs.test.ts index d14d29fd8..fa46caab8 100644 --- a/packages/plugin-rsc/src/transforms/cjs.test.ts +++ b/packages/plugin-rsc/src/transforms/cjs.test.ts @@ -1,8 +1,8 @@ +import path from 'node:path' import { createServer, createServerModuleRunner, parseAstAsync } from 'vite' import { describe, expect, it } from 'vitest' -import { debugSourceMap } from './test-utils' import { transformCjsToEsm } from './cjs' -import path from 'node:path' +import { debugSourceMap } from './test-utils' describe(transformCjsToEsm, () => { async function testTransform(input: string) { diff --git a/packages/plugin-rsc/src/transforms/cjs.ts b/packages/plugin-rsc/src/transforms/cjs.ts index c5781fec7..e48b3920c 100644 --- a/packages/plugin-rsc/src/transforms/cjs.ts +++ b/packages/plugin-rsc/src/transforms/cjs.ts @@ -1,9 +1,9 @@ +import path from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' import type { Program, Node } from 'estree' +import { walk } from 'estree-walker' import MagicString from 'magic-string' import { analyze } from 'periscopic' -import { walk } from 'estree-walker' -import { fileURLToPath, pathToFileURL } from 'node:url' -import path from 'node:path' // TODO: // replacing require("xxx") into import("xxx") affects Vite's resolution. diff --git a/packages/plugin-rsc/src/transforms/fixtures/cjs/entry.mjs b/packages/plugin-rsc/src/transforms/fixtures/cjs/entry.mjs index 63c854c5a..191b45b89 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/cjs/entry.mjs +++ b/packages/plugin-rsc/src/transforms/fixtures/cjs/entry.mjs @@ -1,11 +1,11 @@ import depDefault from './dep1.cjs' import * as depNamespace from './dep2.cjs' -import depFn from './function.cjs' -import depPrimitive from './primitive.cjs' +import dualLib from './dual-lib.cjs' import depExports from './exports.cjs' import depFnRequire from './function-require.cjs' -import dualLib from './dual-lib.cjs' +import depFn from './function.cjs' import cjsGlobals from './globals.cjs' +import depPrimitive from './primitive.cjs' export { depDefault, depNamespace, diff --git a/packages/plugin-rsc/src/utils/encryption-runtime.ts b/packages/plugin-rsc/src/utils/encryption-runtime.ts index 84b307ce0..9c184078e 100644 --- a/packages/plugin-rsc/src/utils/encryption-runtime.ts +++ b/packages/plugin-rsc/src/utils/encryption-runtime.ts @@ -1,5 +1,5 @@ -import encryptionKeySource from 'virtual:vite-rsc/encryption-key' import { once } from '@hiogawa/utils' +import encryptionKeySource from 'virtual:vite-rsc/encryption-key' import { createFromReadableStream, renderToReadableStream } from '../react/rsc' import { arrayToStream, diff --git a/playground/class-components/vite.config.ts b/playground/class-components/vite.config.ts index c9a13540c..2d8605e26 100644 --- a/playground/class-components/vite.config.ts +++ b/playground/class-components/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' export default defineConfig({ server: { port: 8908 /* Should be unique */ }, diff --git a/playground/compiler-react-18/vite.config.ts b/playground/compiler-react-18/vite.config.ts index ec85482a1..08987b47a 100644 --- a/playground/compiler-react-18/vite.config.ts +++ b/playground/compiler-react-18/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig(({ command }) => { diff --git a/playground/compiler/vite.config.ts b/playground/compiler/vite.config.ts index a8bffc7a0..5593e05a5 100644 --- a/playground/compiler/vite.config.ts +++ b/playground/compiler/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig(({ command }) => { diff --git a/playground/hook-with-jsx/vite.config.ts b/playground/hook-with-jsx/vite.config.ts index 6e5b8e40a..3f6f653fd 100644 --- a/playground/hook-with-jsx/vite.config.ts +++ b/playground/hook-with-jsx/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' export default defineConfig({ server: { port: 8909 /* Should be unique */ }, diff --git a/playground/include-node-modules/test-package/package.json b/playground/include-node-modules/test-package/package.json index 99651ea20..9b8cfeb54 100644 --- a/playground/include-node-modules/test-package/package.json +++ b/playground/include-node-modules/test-package/package.json @@ -1,6 +1,6 @@ { "name": "test-package", "version": "1.0.0", - "main": "index.js", - "type": "module" + "type": "module", + "main": "index.js" } diff --git a/playground/include-node-modules/vite.config.ts b/playground/include-node-modules/vite.config.ts index 28c3dd518..27d0da02b 100644 --- a/playground/include-node-modules/vite.config.ts +++ b/playground/include-node-modules/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' import type { PluginItem as BabelPlugin } from '@babel/core' +import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' export default defineConfig({ plugins: [ diff --git a/playground/mdx/vite.config.ts b/playground/mdx/vite.config.ts index 4cee7a4ea..d2ef28345 100644 --- a/playground/mdx/vite.config.ts +++ b/playground/mdx/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' import mdx from '@mdx-js/rollup' +import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig({ diff --git a/playground/react-emotion/src/Counter.tsx b/playground/react-emotion/src/Counter.tsx index d7d88f2c4..f4394d3e5 100644 --- a/playground/react-emotion/src/Counter.tsx +++ b/playground/react-emotion/src/Counter.tsx @@ -1,5 +1,5 @@ -import styled from '@emotion/styled' import { css } from '@emotion/react' +import styled from '@emotion/styled' import { useState } from 'react' // Ensure HMR of styled component alongside other components diff --git a/playground/react/App.jsx b/playground/react/App.jsx index b2e66b30d..ac581e3ee 100644 --- a/playground/react/App.jsx +++ b/playground/react/App.jsx @@ -1,12 +1,12 @@ -import { useState } from 'react' import Button from 'jsx-entry' -import WithQuery from './components/WithQuery?qs-should-not-break-plugin-react' +import { useState } from 'react' import { Accordion } from './components/Accordion' -import Parent from './hmr/parent' +import WithQuery from './components/WithQuery?qs-should-not-break-plugin-react' +import { ContextButton } from './context/ContextButton' +import { CountProvider } from './context/CountProvider' import InjectExportsLater from './hmr/inject-exports-later' import { JsxImportRuntime } from './hmr/jsx-import-runtime' -import { CountProvider } from './context/CountProvider' -import { ContextButton } from './context/ContextButton' +import Parent from './hmr/parent' import { TestImportAttributes } from './import-attributes/test' import { TEST_NON_JSX, TestNonJsx } from './non-jsx/test' diff --git a/playground/ssr-react/vite.config.js b/playground/ssr-react/vite.config.js index d5074ecd5..be0e82669 100644 --- a/playground/ssr-react/vite.config.js +++ b/playground/ssr-react/vite.config.js @@ -1,8 +1,8 @@ import fs from 'node:fs' import path from 'node:path' import url from 'node:url' -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' const _dirname = path.dirname(url.fileURLToPath(import.meta.url)) diff --git a/playground/vitestGlobalSetup.ts b/playground/vitestGlobalSetup.ts index 508ec0f0a..8e1622cf0 100644 --- a/playground/vitestGlobalSetup.ts +++ b/playground/vitestGlobalSetup.ts @@ -1,8 +1,8 @@ import path from 'node:path' import fs from 'fs-extra' -import type { TestProject } from 'vitest/node' import type { BrowserServer } from 'playwright-chromium' import { chromium } from 'playwright-chromium' +import type { TestProject } from 'vitest/node' let browserServer: BrowserServer | undefined diff --git a/playground/vitestSetup.ts b/playground/vitestSetup.ts index 0638b88a5..5aae0731e 100644 --- a/playground/vitestSetup.ts +++ b/playground/vitestSetup.ts @@ -1,6 +1,7 @@ import type * as http from 'node:http' import path, { dirname, resolve } from 'node:path' import fs from 'fs-extra' +import type { Browser, Page } from 'playwright-chromium' import { chromium } from 'playwright-chromium' import type { ConfigEnv, @@ -12,9 +13,6 @@ import type { UserConfig, ViteDevServer, } from 'vite' -import type { Browser, Page } from 'playwright-chromium' -import type { RunnerTestFile } from 'vitest' -import { beforeAll, inject } from 'vitest' import { build, createBuilder, @@ -23,6 +21,8 @@ import { mergeConfig, preview, } from 'vite' +import type { RunnerTestFile } from 'vitest' +import { beforeAll, inject } from 'vitest' // #region env diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a1a884b4..2a2684ac4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,15 +50,15 @@ importers: lint-staged: specifier: ^16.2.7 version: 16.2.7 + oxfmt: + specifier: ^0.23.0 + version: 0.23.0 picocolors: specifier: ^1.1.1 version: 1.1.1 playwright-chromium: specifier: ^1.57.0 version: 1.57.0 - prettier: - specifier: ^3.6.2 - version: 3.6.2 simple-git-hooks: specifier: ^2.13.1 version: 2.13.1 @@ -1735,6 +1735,46 @@ packages: '@oxc-project/types@0.106.0': resolution: {integrity: sha512-QdsH3rZq480VnOHSHgPYOhjL8O8LBdcnSjM408BpPCCUc0JYYZPG9Gafl9i3OcGk/7137o+gweb4cCv3WAUykg==} + '@oxfmt/darwin-arm64@0.23.0': + resolution: {integrity: sha512-shGng2EjBspvuqtFtcjcKf0WoZ9QCdL8iLYgdOoKSiSQ9pPyLJ4jQf62yhm4b2PpZNVcV/20gV6d8SyKzg6SZQ==} + cpu: [arm64] + os: [darwin] + + '@oxfmt/darwin-x64@0.23.0': + resolution: {integrity: sha512-DxQ7Hm7B+6JiIkiRU3CSJmM15nTJDDezyaAv+x9NN8BfU0C49O8JuZIFu1Lr9AKEPV+ECIYM2X4HU0xm6IdiMQ==} + cpu: [x64] + os: [darwin] + + '@oxfmt/linux-arm64-gnu@0.23.0': + resolution: {integrity: sha512-7qTXPpENi45sEKsaYFit4VRywPVkX+ZJc5JVA17KW1coJ/SLUuRAdLjRipU+QTZsr1TF93HCmGFSlUjB7lmEVQ==} + cpu: [arm64] + os: [linux] + + '@oxfmt/linux-arm64-musl@0.23.0': + resolution: {integrity: sha512-qkFXbf+K01B++j69o9mLvvyfhmmL4+qX7hGPA2PRDkE5xxuUTWdqboQQc1FgGI0teUlIYYyxjamq9UztL2A7NA==} + cpu: [arm64] + os: [linux] + + '@oxfmt/linux-x64-gnu@0.23.0': + resolution: {integrity: sha512-J7Q13Ujyn8IgjHD96urA377GOy8HerxC13OrEyYaM8iwH3gc/EoboK9AKu0bxp9qai4btPFDhnkRnpCwJE9pAw==} + cpu: [x64] + os: [linux] + + '@oxfmt/linux-x64-musl@0.23.0': + resolution: {integrity: sha512-3gb25Zk2/y4An8fi399KdpLkDYFTJEB5Nq/sSHmeXG0pZlR/jnKoXEFHsjU+9nqF2wsuZ+tmkoi/swcaGG8+Qg==} + cpu: [x64] + os: [linux] + + '@oxfmt/win32-arm64@0.23.0': + resolution: {integrity: sha512-JKfRP2ENWwRZ73rMZFyChvRi/+oDEW+3obp1XIwecot8gvDHgGZ4nX3hTp4VPiBFL89JORMpWSKzJvjRDucJIw==} + cpu: [arm64] + os: [win32] + + '@oxfmt/win32-x64@0.23.0': + resolution: {integrity: sha512-vgqtYK1X1n/KexCNQKWXao3hyOnmWuCzk2sQyCSpkLhjSNIDPm7dmnEkvOXhf1t0O5RjCwHpk2VB6Fuaq3GULg==} + cpu: [x64] + os: [win32] + '@playwright/test@1.57.0': resolution: {integrity: sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==} engines: {node: '>=18'} @@ -3816,6 +3856,11 @@ packages: resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==} engines: {node: '>= 0.8.0'} + oxfmt@0.23.0: + resolution: {integrity: sha512-dh4rlNBua93aVf2ZaDecbQxVLMnUUTvDi1K1fdvBdontQeEf6K22Z1KQg5QKl2D9aNFeFph+wOVwcjjYUIO6Mw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + p-limit@3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} @@ -4336,6 +4381,10 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tinypool@2.0.0: + resolution: {integrity: sha512-/RX9RzeH2xU5ADE7n2Ykvmi9ED3FBGPAjw9u3zucrNNaEBIO0HPSYgL0NT7+3p147ojeSdaVu08F6hjpv31HJg==} + engines: {node: ^20.0.0 || >=22.0.0} + tinyrainbow@3.0.3: resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==} engines: {node: '>=14.0.0'} @@ -5337,6 +5386,30 @@ snapshots: '@oxc-project/types@0.106.0': {} + '@oxfmt/darwin-arm64@0.23.0': + optional: true + + '@oxfmt/darwin-x64@0.23.0': + optional: true + + '@oxfmt/linux-arm64-gnu@0.23.0': + optional: true + + '@oxfmt/linux-arm64-musl@0.23.0': + optional: true + + '@oxfmt/linux-x64-gnu@0.23.0': + optional: true + + '@oxfmt/linux-x64-musl@0.23.0': + optional: true + + '@oxfmt/win32-arm64@0.23.0': + optional: true + + '@oxfmt/win32-x64@0.23.0': + optional: true + '@playwright/test@1.57.0': dependencies: playwright: 1.57.0 @@ -7408,6 +7481,19 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 + oxfmt@0.23.0: + dependencies: + tinypool: 2.0.0 + optionalDependencies: + '@oxfmt/darwin-arm64': 0.23.0 + '@oxfmt/darwin-x64': 0.23.0 + '@oxfmt/linux-arm64-gnu': 0.23.0 + '@oxfmt/linux-arm64-musl': 0.23.0 + '@oxfmt/linux-x64-gnu': 0.23.0 + '@oxfmt/linux-x64-musl': 0.23.0 + '@oxfmt/win32-arm64': 0.23.0 + '@oxfmt/win32-x64': 0.23.0 + p-limit@3.1.0: dependencies: yocto-queue: 0.1.0 @@ -7953,6 +8039,8 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tinypool@2.0.0: {} + tinyrainbow@3.0.3: {} to-regex-range@5.0.1: