Skip to content

Commit

Permalink
fix: Allow start turbopack dev server for a project using middleware (#…
Browse files Browse the repository at this point in the history
…59759)

### What?

Configures `scoped_tls` (in `swc_common`) correctly.

### Why?

One of the company websites fails to **start**.

https://vercel.slack.com/archives/C03EWR7LGEN/p1702970892605989

### How?

Closes PACK-2165
  • Loading branch information
kdy1 committed Dec 19, 2023
1 parent 63825de commit a65fb16
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/next-swc/crates/next-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use anyhow::{bail, Context, Result};
use indexmap::{IndexMap, IndexSet};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;
use swc_core::ecma::ast::{Expr, Lit, Program};
use swc_core::{
common::GLOBALS,
ecma::ast::{Expr, Lit, Program},
};
use turbo_tasks::{trace::TraceRawVcs, TaskInput, ValueDefault, ValueToString, Vc};
use turbo_tasks_fs::{rope::Rope, util::join_path, File};
use turbopack_binding::{
Expand Down Expand Up @@ -215,6 +218,7 @@ pub async fn parse_config_from_source(module: Vc<Box<dyn Module>>) -> Result<Vc<
{
if let ParseResult::Ok {
program: Program::Module(module_ast),
globals,
eval_context,
..
} = &*ecmascript_asset.parse().await?
Expand All @@ -235,8 +239,10 @@ pub async fn parse_config_from_source(module: Vc<Box<dyn Module>>) -> Result<Vc<
.unwrap_or_default()
{
if let Some(init) = decl.init.as_ref() {
let value = eval_context.eval(init);
return Ok(parse_config_from_js_value(module, &value).cell());
return GLOBALS.set(globals, || {
let value = eval_context.eval(init);
Ok(parse_config_from_js_value(module, &value).cell())
});
} else {
NextSourceConfigParsingIssue {
ident: module.ident(),
Expand Down

0 comments on commit a65fb16

Please sign in to comment.