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 11const { createRequire } = require ( "node:module" ) ;
22const _createJiti = require ( "../dist/jiti.cjs" ) ;
3- const transform = require ( "../dist/babel.cjs" ) ;
43
54function onError ( err ) {
65 throw err ; /* ↓ Check stack trace ↓ */
76}
87
98const nativeImport = ( id ) => import ( id ) ;
109
10+ let _transform ;
11+ function lazyTransform ( ...args ) {
12+ if ( ! _transform ) {
13+ _transform = require ( "../dist/babel.cjs" ) ;
14+ }
15+ return _transform ( ...args ) ;
16+ }
17+
1118function createJiti ( id , opts = { } ) {
1219 if ( ! opts . transform ) {
13- opts = { ...opts , transform } ;
20+ opts = { ...opts , transform : lazyTransform } ;
1421 }
1522 return _createJiti ( id , opts , {
1623 onError,
Original file line number Diff line number Diff line change 11import { createRequire } from "node:module" ;
22import _createJiti from "../dist/jiti.cjs" ;
3- import transform from "../dist/babel.cjs" ;
43
54function onError ( err ) {
65 throw err ; /* ↓ Check stack trace ↓ */
76}
87
98const nativeImport = ( id ) => import ( id ) ;
109
10+ let _transform ;
11+ function lazyTransform ( ...args ) {
12+ if ( ! _transform ) {
13+ _transform = createRequire ( import . meta. url ) ( "../dist/babel.cjs" ) ;
14+ }
15+ return _transform ( ...args ) ;
16+ }
17+
1118export function createJiti ( id , opts = { } ) {
1219 if ( ! opts . transform ) {
13- opts = { ...opts , transform } ;
20+ opts = { ...opts , transform : lazyTransform } ;
1421 }
1522 return _createJiti ( id , opts , {
1623 onError,
You can’t perform that action at this time.
0 commit comments