File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @livekit/agents ' : patch
3+ ---
4+
5+ Fork files with cjs extension when running cjs file
Original file line number Diff line number Diff line change @@ -24,17 +24,24 @@ const defaultOptions: Options = {
2424 // require('../path') → require('../path.cjs') in `.cjs` files
2525 // from './path' → from './path.cjs' in `.cjs` files
2626 // from '../path' → from '../path.cjs' in `.cjs` files
27+ // (0, import_node_child_process.fork)(new URL("./path.js" → (0, import_node_child_process.fork)(new URL("./path.cjs" in `.cjs` files
2728 name : 'fix-cjs-imports' ,
2829 renderChunk ( code ) {
2930 if ( this . format === 'cjs' ) {
3031 const regexCjs = / r e q u i r e \( (?< quote > [ ' " ] ) (?< import > \. [ ^ ' " ] + ) \. j s [ ' " ] \) / g;
3132 const regexDynamic = / i m p o r t \( (?< quote > [ ' " ] ) (?< import > \. [ ^ ' " ] + ) \. j s [ ' " ] \) / g;
3233 const regexEsm = / f r o m (?< space > [ \s ] * ) (?< quote > [ ' " ] ) (?< import > \. [ ^ ' " ] + ) \. j s [ ' " ] / g;
34+ const regexForkCompiled =
35+ / \( 0 , i m p o r t _ n o d e _ c h i l d _ p r o c e s s \. f o r k \) \( n e w U R L \( (?< quote > [ ' " ] ) (?< import > \. \/ [ ^ ' " ] + ) \. j s [ ' " ] / g;
3336 return {
3437 code : code
3538 . replace ( regexCjs , 'require($<quote>$<import>.cjs$<quote>)' )
3639 . replace ( regexDynamic , 'import($<quote>$<import>.cjs$<quote>)' )
37- . replace ( regexEsm , 'from$<space>$<quote>$<import>.cjs$<quote>' ) ,
40+ . replace ( regexEsm , 'from$<space>$<quote>$<import>.cjs$<quote>' )
41+ . replace (
42+ regexForkCompiled ,
43+ '(0, import_node_child_process.fork)(new URL($<quote>$<import>.cjs$<quote>' ,
44+ ) ,
3845 } ;
3946 }
4047 } ,
You can’t perform that action at this time.
0 commit comments