Skip to content

Commit

Permalink
Revert "fix esm require"
Browse files Browse the repository at this point in the history
This reverts commit a87dedb.
  • Loading branch information
ForsakenHarmony committed Apr 22, 2024
1 parent 7e501e0 commit 3b089b2
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions crates/turbopack-ecmascript/src/references/external_module.rs
Expand Up @@ -64,28 +64,18 @@ impl CachedExternalModule {
pub fn content(&self) -> Result<Vc<EcmascriptModuleContent>> {
let mut code = RopeBuilder::default();

match self.external_type {
CachedExternalType::CommonJs => {
writeln!(
code,
"const mod = __turbopack_external_require__({});",
StringifyJs(&self.request)
)?;
}
CachedExternalType::EcmaScriptViaRequire => {
writeln!(
code,
"const mod = __turbopack_external_require__({}, true);",
StringifyJs(&self.request)
)?;
}
CachedExternalType::EcmaScriptViaImport => {
writeln!(
code,
"const mod = await __turbopack_external_import__({});",
StringifyJs(&self.request)
)?;
}
if self.external_type == CachedExternalType::EcmaScriptViaImport {
writeln!(
code,
"const mod = await __turbopack_external_import__({});",
StringifyJs(&self.request)
)?;
} else {
writeln!(
code,
"const mod = __turbopack_external_require__({});",
StringifyJs(&self.request)
)?;
}

writeln!(code)?;
Expand Down

0 comments on commit 3b089b2

Please sign in to comment.