Unverified Commit 840b60bc authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

fix(next-core): do not panic when parsing segment config (#59170)

parent 574e7060
...@@ -4,7 +4,7 @@ use anyhow::{bail, Result}; ...@@ -4,7 +4,7 @@ use anyhow::{bail, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use swc_core::{ use swc_core::{
common::{source_map::Pos, Span, Spanned}, common::{source_map::Pos, Span, Spanned, GLOBALS},
ecma::ast::{Expr, Ident, Program}, ecma::ast::{Expr, Ident, Program},
}; };
use turbo_tasks::{trace::TraceRawVcs, TryJoinIterExt, ValueDefault, Vc}; use turbo_tasks::{trace::TraceRawVcs, TryJoinIterExt, ValueDefault, Vc};
...@@ -243,12 +243,14 @@ pub async fn parse_segment_config_from_source( ...@@ -243,12 +243,14 @@ pub async fn parse_segment_config_from_source(
let ParseResult::Ok { let ParseResult::Ok {
program: Program::Module(module_ast), program: Program::Module(module_ast),
eval_context, eval_context,
globals,
.. ..
} = result } = result
else { else {
return Ok(Default::default()); return Ok(Default::default());
}; };
let config = GLOBALS.set(globals, || {
let mut config = NextSegmentConfig::default(); let mut config = NextSegmentConfig::default();
for item in &module_ast.body { for item in &module_ast.body {
...@@ -270,6 +272,8 @@ pub async fn parse_segment_config_from_source( ...@@ -270,6 +272,8 @@ pub async fn parse_segment_config_from_source(
} }
} }
} }
config
});
Ok(config.cell()) Ok(config.cell())
} }
......
...@@ -6365,11 +6365,12 @@ ...@@ -6365,11 +6365,12 @@
"runtimeError": false "runtimeError": false
}, },
"test/integration/app-dir-export/test/dynamic-missing-gsp-dev.test.ts": { "test/integration/app-dir-export/test/dynamic-missing-gsp-dev.test.ts": {
"passed": [], "passed": [
"failed": [
"app dir - with output export - dynamic missing gsp dev development mode should error when client component has generateStaticParams",
"app dir - with output export - dynamic missing gsp dev development mode should error when dynamic route is missing generateStaticParams" "app dir - with output export - dynamic missing gsp dev development mode should error when dynamic route is missing generateStaticParams"
], ],
"failed": [
"app dir - with output export - dynamic missing gsp dev development mode should error when client component has generateStaticParams"
],
"pending": [], "pending": [],
"flakey": [], "flakey": [],
"runtimeError": false "runtimeError": false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment