File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,15 @@ import { TypeScriptCompileError } from "./typescript-compile-error";
5
5
export function TypeScriptLoader ( options ?: RegisterOptions ) : Loader {
6
6
return ( path : string , content : string ) => {
7
7
try {
8
- register ( options ) . compile ( content , path ) ;
8
+ // cosmiconfig requires the transpiled configuration to be CJS
9
+ register ( { ...options , compilerOptions : { module : "commonjs" } } ) . compile (
10
+ content ,
11
+ path
12
+ ) ;
9
13
const result = require ( path ) ;
10
14
11
- /**
12
- * `default` is used when exporting using export default, some modules
13
- * may still use `module.exports` or if in TS `export = `
14
- */
15
+ // `default` is used when exporting using export default, some modules
16
+ // may still use `module.exports` or if in TS `export = `
15
17
return result . default || result ;
16
18
} catch ( error ) {
17
19
if ( error instanceof Error ) {
You can’t perform that action at this time.
0 commit comments