From b4c9dad1428c0974b6af8ad5209bfc2b913fd95b Mon Sep 17 00:00:00 2001 From: Homyee King Date: Fri, 27 Sep 2024 11:23:00 +0800 Subject: [PATCH] fix: babel jsx-runtime (#659) * fix: babel jsx-runtime * chore: changeset * fix: cr --- .changeset/silly-grapes-knock.md | 5 +++++ packages/pkg/src/constants.ts | 1 + packages/pkg/src/helpers/getBabelOptions.ts | 2 ++ packages/pkg/src/rollupPlugins/swc.ts | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/silly-grapes-knock.md create mode 100644 packages/pkg/src/constants.ts diff --git a/.changeset/silly-grapes-knock.md b/.changeset/silly-grapes-knock.md new file mode 100644 index 00000000..d69fbdc1 --- /dev/null +++ b/.changeset/silly-grapes-knock.md @@ -0,0 +1,5 @@ +--- +'@ice/pkg': patch +--- + +fix: babel jsx importSource diff --git a/packages/pkg/src/constants.ts b/packages/pkg/src/constants.ts new file mode 100644 index 00000000..0251b07f --- /dev/null +++ b/packages/pkg/src/constants.ts @@ -0,0 +1 @@ +export const JSX_RUNTIME_SOURCE = '@ice/jsx-runtime'; diff --git a/packages/pkg/src/helpers/getBabelOptions.ts b/packages/pkg/src/helpers/getBabelOptions.ts index 8f8e9d90..1d35322d 100644 --- a/packages/pkg/src/helpers/getBabelOptions.ts +++ b/packages/pkg/src/helpers/getBabelOptions.ts @@ -1,5 +1,6 @@ import { TransformOptions } from '@babel/core'; import { BabelPluginOptions } from 'src/rollupPlugins/babel.js'; +import { JSX_RUNTIME_SOURCE } from '../constants.js'; function getBabelOptions( plugins: babel.PluginItem[], @@ -27,6 +28,7 @@ function getBabelOptions( jsxRuntime === 'automatic' ? { runtime: jsxRuntime, + importSource: JSX_RUNTIME_SOURCE } : { pragma, diff --git a/packages/pkg/src/rollupPlugins/swc.ts b/packages/pkg/src/rollupPlugins/swc.ts index aea894b8..2cc767f9 100644 --- a/packages/pkg/src/rollupPlugins/swc.ts +++ b/packages/pkg/src/rollupPlugins/swc.ts @@ -8,8 +8,8 @@ import MagicString from 'magic-string'; import type { Options as SwcCompileOptions, Config, TsParserConfig, EsParserConfig } from '@swc/core'; import type { TaskConfig, OutputFile, BundleTaskConfig } from '../types.js'; import type { Plugin } from 'rollup'; +import { JSX_RUNTIME_SOURCE } from '../constants.js'; -const JSX_RUNTIME_SOURCE = '@ice/jsx-runtime'; const normalizeSwcConfig = ( file: OutputFile,