File tree Expand file tree Collapse file tree 6 files changed +66
-16
lines changed
Expand file tree Collapse file tree 6 files changed +66
-16
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoaderSync();
2020
2121 console . info ( "Loaded with CJS successfully" ) ;
2222 } catch ( error ) {
23- console . error ( error ) ;
24- console . debug ( error . stack ) ;
25- console . error ( "Failed to load with CJS" ) ;
23+ console . error ( "Failed to load configuration with CJS" ) ;
24+ if ( error instanceof TypeError ) {
25+ console . error ( "Type error occurred:" , error . message ) ;
26+ } else if ( error instanceof SyntaxError ) {
27+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28+ } else {
29+ console . error ( "An unexpected error occurred:" , error . message ) ;
30+ }
31+ console . debug ( "Error stack trace:" , error . stack ) ;
2632 process . exit ( 1 ) ;
2733 }
2834} ) ( ) ;
Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoader();
2020
2121 console . info ( "Loaded with CJS successfully" ) ;
2222 } catch ( error ) {
23- console . error ( error ) ;
24- console . debug ( error . stack ) ;
25- console . error ( "Failed to load with CJS" ) ;
23+ console . error ( "Failed to load configuration with CJS" ) ;
24+ if ( error instanceof TypeError ) {
25+ console . error ( "Type error occurred:" , error . message ) ;
26+ } else if ( error instanceof SyntaxError ) {
27+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28+ } else {
29+ console . error ( "An unexpected error occurred:" , error . message ) ;
30+ }
31+ console . debug ( "Error stack trace:" , error . stack ) ;
2632 process . exit ( 1 ) ;
2733 }
2834} ) ( ) ;
Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoaderSync();
2020
2121 console . info ( "Loaded with ESM successfully" ) ;
2222 } catch ( error ) {
23- console . error ( error ) ;
24- console . debug ( error . stack ) ;
25- console . error ( "Failed to load with ESM" ) ;
23+ console . error ( "Failed to load configuration with ESM" ) ;
24+ if ( error instanceof TypeError ) {
25+ console . error ( "Type error occurred:" , error . message ) ;
26+ } else if ( error instanceof SyntaxError ) {
27+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28+ } else {
29+ console . error ( "An unexpected error occurred:" , error . message ) ;
30+ }
31+ console . debug ( "Error stack trace:" , error . stack ) ;
2632 process . exit ( 1 ) ;
2733 }
2834} ) ( ) ;
Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoader();
2020
2121 console . info ( "Loaded with ESM successfully" ) ;
2222 } catch ( error ) {
23- console . error ( error ) ;
24- console . debug ( error . stack ) ;
25- console . error ( "Failed to load with ESM" ) ;
23+ console . error ( "Failed to load configuration with ESM" ) ;
24+ if ( error instanceof TypeError ) {
25+ console . error ( "Type error occurred:" , error . message ) ;
26+ } else if ( error instanceof SyntaxError ) {
27+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28+ } else {
29+ console . error ( "An unexpected error occurred:" , error . message ) ;
30+ }
31+ console . debug ( "Error stack trace:" , error . stack ) ;
2632 process . exit ( 1 ) ;
2733 }
2834} ) ( ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,19 @@ const assert = require("node:assert");
1212 assert . strictEqual ( typeof cjs === "function" , true ) ;
1313
1414 // Try to create loaders
15- esm ( ) ;
16- cjs ( ) ;
15+ const esmResult = esm ( { } ) ;
16+ const cjsResult = cjs ( { } ) ;
17+
18+ assert . strictEqual (
19+ typeof esmResult ,
20+ "function" ,
21+ "ESM loader should return an function" ,
22+ ) ;
23+ assert . strictEqual (
24+ typeof cjsResult ,
25+ "function" ,
26+ "CJS loader should return an function" ,
27+ ) ;
1728
1829 console . info ( "Loaded with both CJS and ESM successfully" ) ;
1930 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -12,8 +12,23 @@ const assert = require("node:assert");
1212 assert . strictEqual ( typeof cjs === "function" , true ) ;
1313
1414 // Try to create loaders
15- esm ( ) ;
16- cjs ( ) ;
15+ const esmResult = await esm ( {
16+ /* mock config */
17+ } ) ;
18+ const cjsResult = await cjs ( {
19+ /* mock config */
20+ } ) ;
21+
22+ assert . strictEqual (
23+ typeof esmResult ,
24+ "function" ,
25+ "ESM loader should return an function" ,
26+ ) ;
27+ assert . strictEqual (
28+ typeof cjsResult ,
29+ "function" ,
30+ "CJS loader should return an function" ,
31+ ) ;
1732
1833 console . info ( "Loaded with both CJS and ESM successfully" ) ;
1934 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments