File tree 8 files changed +51
-7
lines changed
8 files changed +51
-7
lines changed Original file line number Diff line number Diff line change 9
9
" esbuild.config.mjs" ,
10
10
" jest.config.ts" ,
11
11
" coverage" ,
12
- " dist"
12
+ " dist" ,
13
+ " smoke-tests"
13
14
],
14
15
"rules" : {
15
16
"@typescript-eslint/await-thenable" : " warn" ,
Original file line number Diff line number Diff line change 30
30
id : test
31
31
if : ${{ always() }}
32
32
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
33
42
- name : lint
34
43
if : ${{ always() }}
35
44
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:
22
22
23
23
``` ts
24
24
import { cosmiconfig } from " cosmiconfig" ;
25
- import TypeScriptLoader from " cosmiconfig-typescript-loader" ;
25
+ import { TypeScriptLoader } from " cosmiconfig-typescript-loader" ;
26
26
27
27
const moduleName = " module" ;
28
28
const explorer = cosmiconfig (" test" , {
@@ -51,7 +51,7 @@ Or more simply if you only support loading of a TypeScript based configuration f
51
51
52
52
``` ts
53
53
import { cosmiconfig } from " cosmiconfig" ;
54
- import TypeScriptLoader from " cosmiconfig-typescript-loader" ;
54
+ import { TypeScriptLoader } from " cosmiconfig-typescript-loader" ;
55
55
56
56
const moduleName = " module" ;
57
57
const explorer = cosmiconfig (" test" , {
Original file line number Diff line number Diff line change 1
1
import path from "path" ;
2
2
import { cosmiconfig , cosmiconfigSync } from "cosmiconfig" ;
3
- import TypeScriptLoader from "." ;
3
+ import { TypeScriptLoader } from "." ;
4
4
5
5
describe ( "TypeScriptLoader" , ( ) => {
6
6
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" ;
4
2
export 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