Skip to content

Commit 0b0a5c1

Browse files
committed
Fix typecast export
1 parent 1546b35 commit 0b0a5c1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/next-core/src/segment_config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use swc_core::{
88
ecma::{
99
ast::{
1010
ClassExpr, Decl, ExportSpecifier, Expr, ExprStmt, FnExpr, Lit, ModuleDecl,
11-
ModuleExportName, ModuleItem, Program, Stmt, Str,
11+
ModuleExportName, ModuleItem, Program, Stmt, Str, TsSatisfiesExpr,
1212
},
1313
utils::IsDirective,
1414
},
@@ -498,7 +498,15 @@ async fn parse_config_value(
498498
span: Span,
499499
) -> Result<()> {
500500
let get_value = || {
501-
init.map(|init| eval_context.eval(&init)).map(|v| {
501+
let init = init.as_deref();
502+
// Unwrap `export const config = { .. } satisfies MiddlewareConfig`, usually this is already
503+
// transpiled away, but we are looking at the original source here.
504+
let init = if let Some(Expr::TsSatisfies(TsSatisfiesExpr { expr, .. })) = init {
505+
Some(&**expr)
506+
} else {
507+
init
508+
};
509+
init.map(|init| eval_context.eval(init)).map(|v| {
502510
// Special case, as we don't call `link` here: assume that `undefined` is a free
503511
// variable.
504512
if let JsValue::FreeVar(name) = &v

0 commit comments

Comments
 (0)