File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed
Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ function interopDefault(mod: any): any {
135135 if ( Reflect . has ( target , prop ) ) {
136136 return Reflect . get ( target , prop , receiver ) ;
137137 }
138- if ( defIsObj ) {
138+ if ( defIsObj && ! ( ( def instanceof Promise ) /** issue: #400 */ ) ) {
139139 let fallback = Reflect . get ( def , prop , receiver ) ;
140140 if ( typeof fallback === "function" ) {
141141 fallback = fallback . bind ( def ) ;
Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ exports[`fixtures > esm > stdout 1`] = `
5555} "
5656` ;
5757
58+ exports [` fixtures > export-promise > stdout 1` ] = `
59+ "module: [Module: null prototype] {
60+ bar : ' bar' ,
61+ default : Promise { 'foo' },
62+ foo : [AsyncFunction : foo ]
63+ }
64+ default module: foo"
65+ ` ;
66+
5867exports [` fixtures > hashbang > stdout 1` ] = ` "1"` ;
5968
6069exports [` fixtures > import-map > stdout 1` ] = ` "{ alias : ' alias' } "` ;
Original file line number Diff line number Diff line change 1+ export const foo = async ( ) => "foo" ;
2+ export const bar = "bar" ;
3+
4+ export default foo ( ) ;
Original file line number Diff line number Diff line change 1+ import { createJiti } from "../../../lib/jiti.cjs" ;
2+
3+ async function main ( ) {
4+ const jiti = createJiti ( import . meta. url ) ;
5+
6+ const mod = await jiti . import ( "./export-promise.mjs" , { default : false } ) ;
7+ console . log ( "module:" , mod ) ;
8+
9+ const defaultMod = await jiti . import ( "./export-promise.mjs" , {
10+ default : true ,
11+ } ) ;
12+ console . log ( "default module:" , defaultMod ) ;
13+ }
14+
15+ main ( ) . catch ( ( error_ ) => {
16+ console . error ( "Error:" , error_ ) ;
17+ } ) ;
You can’t perform that action at this time.
0 commit comments