From 585d6c98029c5df12a9f09a438590e27a590a22e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:21:34 +0000 Subject: [PATCH 1/4] Initial plan From 08382e5651b52d2c387cb344089817a6a3629bcf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:27:22 +0000 Subject: [PATCH 2/4] Remove __filename and __dirname checks from plugin-react-swc Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com> --- packages/plugin-react-swc/src/index.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 8beeda5d..282d0122 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -21,15 +21,8 @@ import { import * as vite from 'vite' import { exactRegex } from '@rolldown/pluginutils' -/* eslint-disable no-restricted-globals */ -const _dirname = - typeof __dirname !== 'undefined' - ? __dirname - : dirname(fileURLToPath(import.meta.url)) -const resolve = createRequire( - typeof __filename !== 'undefined' ? __filename : import.meta.url, -).resolve -/* eslint-enable no-restricted-globals */ +const _dirname = dirname(fileURLToPath(import.meta.url)) +const resolve = createRequire(import.meta.url).resolve type Options = { /** From 941e09019d06433f14b01346aaaaaef1f5b2e707 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 13:42:36 +0000 Subject: [PATCH 3/4] Use import.meta.dirname instead of computing _dirname manually Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com> --- packages/plugin-react-swc/src/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index 282d0122..de4e1403 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -1,6 +1,5 @@ import { readFileSync } from 'node:fs' -import { dirname, join } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'node:path' import { createRequire } from 'node:module' import { type JscTarget, @@ -21,7 +20,6 @@ import { import * as vite from 'vite' import { exactRegex } from '@rolldown/pluginutils' -const _dirname = dirname(fileURLToPath(import.meta.url)) const resolve = createRequire(import.meta.url).resolve type Options = { @@ -107,7 +105,8 @@ const react = (_options?: Options): Plugin[] => { handler: (id) => id === runtimePublicPath ? readFileSync( - join(_dirname, 'refresh-runtime.js'), + // eslint-disable-next-line n/no-unsupported-features/node-builtins -- import.meta.dirname is supported in Node.js 20.11.0+ + join(import.meta.dirname, 'refresh-runtime.js'), 'utf-8', ).replace( /__README_URL__/g, From 793bcccde34f6ef91eec4aa5b223c971b39fbd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0?= Date: Tue, 14 Oct 2025 22:50:55 +0900 Subject: [PATCH 4/4] chore: update comment --- packages/plugin-react-swc/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-react-swc/src/index.ts b/packages/plugin-react-swc/src/index.ts index de4e1403..24250181 100644 --- a/packages/plugin-react-swc/src/index.ts +++ b/packages/plugin-react-swc/src/index.ts @@ -105,7 +105,7 @@ const react = (_options?: Options): Plugin[] => { handler: (id) => id === runtimePublicPath ? readFileSync( - // eslint-disable-next-line n/no-unsupported-features/node-builtins -- import.meta.dirname is supported in Node.js 20.11.0+ + // eslint-disable-next-line n/no-unsupported-features/node-builtins -- import.meta.dirname is stable in the newer versions and the API has not changed join(import.meta.dirname, 'refresh-runtime.js'), 'utf-8', ).replace(