File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 11import { createUnplugin } from 'unplugin' ;
22import { parse } from '@babel/parser' ;
3- import traverse from '@babel/traverse' ;
4- import generate from '@babel/generator' ;
3+ import traverseDefault from '@babel/traverse' ;
4+ import generateDefault from '@babel/generator' ;
55import * as t from '@babel/types' ;
66
7+ // Handle ESM/CJS interop
8+ const traverse = ( traverseDefault as any ) . default || traverseDefault ;
9+ const generate = ( generateDefault as any ) . default || generateDefault ;
10+
711export interface CompilerOptions { }
812
913export const unplugin = createUnplugin < CompilerOptions > ( ( options = { } ) => {
1014 return {
15+ enforce : 'pre' ,
1116 name : '@compiler/core' ,
1217
1318 buildStart ( ) {
@@ -36,7 +41,7 @@ export const unplugin = createUnplugin<CompilerOptions>((options = {}) => {
3641 } ) ;
3742
3843 traverse ( ast , {
39- JSXText ( path ) {
44+ JSXText ( path : any ) {
4045 const value = path . node . value ;
4146 // Check if text is non-empty and meaningful (not just whitespace)
4247 if ( value . trim ( ) . length > 0 ) {
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ import react from '@vitejs/plugin-react';
33import compiler from '@compiler/core/vite' ;
44
55export default defineConfig ( {
6- plugins : [ compiler ( ) , react ( ) ] ,
6+ plugins : [ compiler ( { } ) , react ( ) ] ,
77} ) ;
You can’t perform that action at this time.
0 commit comments