Skip to content

Commit

Permalink
ESM external should give a namespace object
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 21, 2023
1 parent 45bbec6 commit 3b02956
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ interface RequireContextEntry {
external: boolean;
}

type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;
type ExternalRequire = (
id: ModuleId,
esm?: boolean
) => Exports | EsmNamespaceObject;
type ExternalImport = (id: ModuleId) => Promise<Exports | EsmNamespaceObject>;

interface TurbopackDevContext extends TurbopackDevBaseContext {
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/references/esm/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl CodeGenerateable for EsmAssetReference {
)
} else {
quote!(
"var $name = __turbopack_external_require__($id);" as Stmt,
"var $name = __turbopack_external_require__($id, true);" as Stmt,
name = Ident::new(ident.clone().into(), DUMMY_SP),
id: Expr = Expr::Lit(request.clone().into())
)
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/references/esm/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl CodeGenerateable for EsmAsyncAssetReference {
call_expr.callee = Callee::Expr(quote_expr!("Promise.resolve().then"));
call_expr.args = vec![
ExprOrSpread { spread: None, expr: quote_expr!(
"() => __turbopack_external_require__($arg)",
"() => __turbopack_external_require__($arg, true)",
arg: Expr = expr
) },
];
Expand Down

0 comments on commit 3b02956

Please sign in to comment.