Unverified Commit 16e3f537 authored by Leah's avatar Leah Committed by GitHub

fix(turbopack): prevent edge entrypoint from becoming an async module (#59818)

### Why?

We can't await the entrypoint of the edge bundle, so it has to not be
async.

Closes PACK-2171
parent 377c5eb8
...@@ -18,12 +18,17 @@ pub async fn wrap_edge_entry( ...@@ -18,12 +18,17 @@ pub async fn wrap_edge_entry(
entry: Vc<Box<dyn Module>>, entry: Vc<Box<dyn Module>>,
pathname: String, pathname: String,
) -> Result<Vc<Box<dyn Module>>> { ) -> Result<Vc<Box<dyn Module>>> {
// The wrapped module could be an async module, we handle that with the proxy
// here. The comma expression makes sure we don't call the function with the
// module as the "this" arg.
let source = formatdoc!( let source = formatdoc!(
r#" r#"
import * as module from "MODULE"
self._ENTRIES ||= {{}} self._ENTRIES ||= {{}}
self._ENTRIES[{}] = module self._ENTRIES[{}] = new Proxy(Promise.resolve(require('MODULE')), {{
get(modProm, name) {{
return (...args) => modProm.then(mod => (0, mod[name])(...args))
}}
}})
"#, "#,
StringifyJs(&format_args!("middleware_{}", pathname)) StringifyJs(&format_args!("middleware_{}", pathname))
); );
......
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