File tree Expand file tree Collapse file tree 8 files changed +51
-7
lines changed
Expand file tree Collapse file tree 8 files changed +51
-7
lines changed Original file line number Diff line number Diff line change 99 " esbuild.config.mjs" ,
1010 " jest.config.ts" ,
1111 " coverage" ,
12- " dist"
12+ " dist" ,
13+ " smoke-tests"
1314 ],
1415 "rules" : {
1516 "@typescript-eslint/await-thenable" : " warn" ,
Original file line number Diff line number Diff line change 3030 id : test
3131 if : ${{ always() }}
3232 run : npm run test
33+ - name : Import with CJS
34+ if : ${{ always() }}
35+ run : node smoke-tests/smoke-test-cjs.js
36+ - name : Import with ESM
37+ if : ${{ always() }}
38+ run : node smoke-tests/smoke-test-esm.mjs
39+ - name : Import with both CJS and ESM
40+ if : ${{ always() }}
41+ run : node smoke-tests/smoke-test.js
3342 - name : lint
3443 if : ${{ always() }}
3544 run : npm run lint
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ Simply add `TypeScriptLoader` to the list of loaders for the `.ts` file type:
2222
2323``` ts
2424import { cosmiconfig } from " cosmiconfig" ;
25- import TypeScriptLoader from " cosmiconfig-typescript-loader" ;
25+ import { TypeScriptLoader } from " cosmiconfig-typescript-loader" ;
2626
2727const moduleName = " module" ;
2828const explorer = cosmiconfig (" test" , {
@@ -51,7 +51,7 @@ Or more simply if you only support loading of a TypeScript based configuration f
5151
5252``` ts
5353import { cosmiconfig } from " cosmiconfig" ;
54- import TypeScriptLoader from " cosmiconfig-typescript-loader" ;
54+ import { TypeScriptLoader } from " cosmiconfig-typescript-loader" ;
5555
5656const moduleName = " module" ;
5757const explorer = cosmiconfig (" test" , {
Original file line number Diff line number Diff line change 11import path from "path" ;
22import { cosmiconfig , cosmiconfigSync } from "cosmiconfig" ;
3- import TypeScriptLoader from "." ;
3+ import { TypeScriptLoader } from "." ;
44
55describe ( "TypeScriptLoader" , ( ) => {
66 const fixturesPath = path . resolve ( __dirname , "__fixtures__" ) ;
Original file line number Diff line number Diff line change 1- import { TypeScriptLoader } from "./loader" ;
2-
3- export default TypeScriptLoader ;
1+ export { TypeScriptLoader } from "./loader" ;
42export type { TypeScriptCompileError } from "./typescript-compile-error" ;
Original file line number Diff line number Diff line change 1+ const mod = require ( "../dist/cjs/index.js" ) ;
2+ const { TypeScriptLoader } = mod ;
3+ TypeScriptLoader ( ) ;
4+
5+ console . info ( "Loaded with CJS successfully" ) ;
Original file line number Diff line number Diff line change 1+ import mod from "../dist/cjs/index.js" ;
2+ const { TypeScriptLoader } = mod ;
3+ TypeScriptLoader ( ) ;
4+
5+ console . info ( "Loaded with ESM successfully" ) ;
Original file line number Diff line number Diff line change 1+ const assert = require ( "node:assert" ) ;
2+
3+ ( async ( ) => {
4+ try {
5+ const esm = await import ( "../dist/cjs/index.js" ) ;
6+ const cjs = require ( "../dist/cjs/index.js" ) ;
7+
8+ assert . strictEqual (
9+ esm . TypeScriptLoader ,
10+ cjs . TypeScriptLoader ,
11+ "esm.TypeScriptLoader === cjs.TypeScriptLoader"
12+ ) ;
13+
14+ // try to create loaders
15+ esm . TypeScriptLoader ( ) ;
16+ cjs . TypeScriptLoader ( ) ;
17+
18+ console . info ( "Loaded with both CJS and ESM successfully" ) ;
19+ } catch ( error ) {
20+ console . error ( error ) ;
21+ console . debug ( error . stack ) ;
22+
23+ // Prevent an unhandled rejection, exit gracefully.
24+ process . exit ( 1 ) ;
25+ }
26+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments