File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import type { MinifyOptions } from "oxc-minify";
22import type { OXCOptions } from "nitro/types" ;
33import type { Plugin } from "rollup" ;
44
5- import { transform } from "oxc-transform" ;
5+ import { transformSync } from "oxc-transform" ;
66import { minifySync } from "oxc-minify" ;
77
88export function oxc (
@@ -15,10 +15,14 @@ export function oxc(
1515 id : / ^ (? ! .* \/ n o d e _ m o d u l e s \/ ) .* \. m ? [ j t ] s x ? $ / ,
1616 } ,
1717 handler ( code , id ) {
18- return transform ( id , code , {
18+ const res = transformSync ( id , code , {
1919 sourcemap : options . sourcemap ,
2020 ...options . transform ,
2121 } ) ;
22+ if ( res . errors ?. length > 0 ) {
23+ this . error ( res . errors . join ( "\n" ) ) ;
24+ }
25+ return res ;
2226 } ,
2327 } ,
2428 renderChunk ( code , chunk ) {
Original file line number Diff line number Diff line change @@ -46,8 +46,18 @@ export function routeMeta(nitro: Nitro) {
4646 let meta : NitroEventHandler [ "meta" ] | null = null ;
4747
4848 try {
49- const jsCode = transformSync ( id , code ) . code ;
50- const ast = this . parse ( jsCode ) ;
49+ const transformRes = transformSync ( id , code ) ;
50+ if ( transformRes . errors ?. length > 0 ) {
51+ for ( const error of transformRes . errors ) {
52+ this . warn ( error ) ;
53+ }
54+ return {
55+ code : `export default {};` ,
56+ map : null ,
57+ } ;
58+ }
59+
60+ const ast = this . parse ( transformRes . code ) ;
5161 for ( const node of ast . body ) {
5262 if (
5363 node . type === "ExpressionStatement" &&
You can’t perform that action at this time.
0 commit comments