Skip to content
Draft
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
10 changes: 10 additions & 0 deletions .oxfmtrc.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: Import sorting (experimentalSortImports) is intentionally not enabled based on #945 feedback—the ordering behavior (alphabetical with relative imports first) was suboptimal and caused issues with side-effect imports. Can be revisited once oxfmt improves this.

oxfmt should have improved this. Try and see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enabled experimentalSortImports in commit b90e76c. The import sorting now works well - imports are grouped with newlines between groups. Also disabled the eslint import-x/order and sort-imports rules since oxfmt handles this now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot let's reduce the non-essential further by tweaking options (cf. oxc-project/oxc#14253 (comment)). For example options.partitionByNewline.

The big diff is expected only inside packages/plugin-rsc since we haven't used any sorting there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added partitionByNewline: true (with newlinesBetween: false) in commit ec6ff45. This preserves existing import groupings and reduces the diff from 265 to 105 files, with most changes now in packages/plugin-rsc as expected.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 80,
"semi": false,
"singleQuote": true,
"experimentalSortImports": {
"newlinesBetween": false,
"partitionByNewline": true
}
}
31 changes: 16 additions & 15 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -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'
// @ts-check
import { builtinModules } from 'node:module'
Copy link
Member

Choose a reason for hiding this comment

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

This is taste but I like to keep node: module first

import tseslint from 'typescript-eslint'

export default tseslint.config(
{
Expand Down Expand Up @@ -103,17 +103,18 @@ 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,
},
],
// import ordering handled by oxfmt
Copy link
Member

Choose a reason for hiding this comment

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

Let's delete the code instead of commented it

// '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',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"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",
Expand All @@ -44,6 +44,7 @@
"fs-extra": "^11.3.2",
"globals": "^16.5.0",
"lint-staged": "^16.2.7",
"oxfmt": "^0.16.0",
"picocolors": "^1.1.1",
"playwright-chromium": "^1.57.0",
"prettier": "^3.6.2",
Expand All @@ -58,8 +59,8 @@
"pre-commit": "pnpm exec lint-staged --concurrent false"
},
"lint-staged": {
"*": [
"prettier --write --cache --ignore-unknown"
"*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue,astro,svelte,json,jsonc}": [
"oxfmt"
],
"packages/*/{src,types}/**/*.ts": [
"eslint --cache --fix"
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-react-oxc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'

const _dirname = dirname(fileURLToPath(import.meta.url))
const refreshRuntimePath = join(_dirname, 'refresh-runtime.js')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -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 })],
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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' })],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/hmr/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/mdx/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -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', {}]] })],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/ts-lib/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync, writeFileSync } from 'node:fs'
import { type Locator, type Page, expect } from '@playwright/test'
import { readFileSync, writeFileSync } from 'node:fs'
import {
build,
createServer,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playground/worker/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [react()],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react-swc/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileURLToPath } from 'node:url'
import { type PlaywrightTestConfig, devices } from '@playwright/test'
import fs from 'fs-extra'
import { fileURLToPath } from 'node:url'

const tempDir = fileURLToPath(new URL('playground-temp', import.meta.url))
fs.ensureDirSync(tempDir)
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-react-swc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { createRequire } from 'node:module'
import type { Plugin } from 'vite'
import { exactRegex } from '@rolldown/pluginutils'
import {
type JscTarget,
type Output,
Expand All @@ -9,16 +8,17 @@ import {
type Options as SWCOptions,
transform,
} from '@swc/core'
import type { Plugin } from 'vite'
import {
addRefreshWrapper,
getPreambleCode,
runtimePublicPath,
silenceUseClientWarning,
virtualPreamblePlugin,
} from '@vitejs/react-common'
import { readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join } from 'node:path'
import * as vite from 'vite'
import { exactRegex } from '@rolldown/pluginutils'

const resolve = createRequire(import.meta.url).resolve

Expand Down
18 changes: 9 additions & 9 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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,
Expand All @@ -14,10 +13,11 @@ import {
silenceUseClientWarning,
virtualPreamblePlugin,
} from '@vitejs/react-common'
import {
exactRegex,
makeIdFiltersToMatchWithQuery,
} from '@rolldown/pluginutils'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { createFilter } from 'vite'
Copy link
Member

@ArnaudBarre ArnaudBarre Dec 2, 2025

Choose a reason for hiding this comment

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

I'm not a fan of having all type import before runtime ones, it create more diffing when switching from type import to runtime or the other way around and when importing both types and import (I personally like them to be merged) it's cleaner to have them next to each other IMO if not merged

import * as vite from 'vite'

const _dirname = dirname(fileURLToPath(import.meta.url))
const refreshRuntimePath = join(_dirname, 'refresh-runtime.js')
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react/tests/rolldown.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-rsc/e2e/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { createHash } from 'node:crypto'
import { readFileSync } from 'node:fs'
import {
type Page,
type Response as PlaywrightResponse,
expect,
test,
} from '@playwright/test'
import { createHash } from 'node:crypto'
import { readFileSync } from 'node:fs'
import path from 'node:path'
import { x } from 'tinyexec'
import { normalizePath, type Rollup } from 'vite'
import { type Fixture, useCreateEditor, useFixture } from './fixture'
import {
expectNoPageError,
expectNoReload,
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' })
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test'
import fs from 'node:fs'
import path from 'node:path'
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
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/build-app.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/error.test.ts
Original file line number Diff line number Diff line change
@@ -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"', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/fixture.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import test from '@playwright/test'
import assert from 'node:assert'
import { type SpawnOptions, spawn } from 'node:child_process'
import fs from 'node:fs'
import path from 'node:path'
import { stripVTControlCharacters, styleText } from 'node:util'
import test from '@playwright/test'
import { x } from 'tinyexec'

function runCli(options: { command: string; label?: string } & SpawnOptions) {
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-rsc/e2e/isolated.test.ts
Original file line number Diff line number Diff line change
@@ -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 { 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
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rsc/e2e/no-ssr.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from '@playwright/test'
import fs from 'node:fs'
import path from 'node:path'
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' })
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/e2e/react-compiler.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Loading