Skip to content

Commit de33b68

Browse files
committed
🔥 fix dev | prod mode
1 parent 4cad16a commit de33b68

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/core/transformer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function changeREOnBuildStart() {
1010

1111
export async function transform(options: TransformOptions) {
1212
let index = 0
13-
const { code, id, components, resolvers, local } = options
13+
const { code, id, components, resolvers, local, mode } = options
1414

1515
const matches = Array.from(code.original.matchAll(reactComponentRE)).map(item => ({
1616
name: item[1],
@@ -28,7 +28,7 @@ export async function transform(options: TransformOptions) {
2828
const replacedName = `_unplugin_react_${name}_${index}`
2929
index++
3030

31-
code.replaceAll(original, `_jsxDEV(${replacedName}`)
31+
code.replaceAll(original, `${mode === 'dev' ? '_jsxDEV' : 'jsx'}(${replacedName}`)
3232

3333
const importedPath = path
3434

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default createUnplugin<Options>((options = {}) => {
4646
rootDir: options.rootDir!,
4747
resolvers: options.resolvers!,
4848
local: options.local!,
49+
mode: options.mode!,
4950
id,
5051
}
5152

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface TransformOptions {
8383
rootDir: string
8484
resolvers: Resolvers
8585
local: boolean
86+
mode: Options['mode']
8687
}
8788

8889
export interface GenerateDtsOptions {

0 commit comments

Comments
 (0)