-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
374 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
turbopack/crates/turbopack-ecmascript/src/references/ident.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use anyhow::Result; | ||
use swc_core::{ecma::ast::Expr, quote}; | ||
use turbo_tasks::{RcStr, Vc}; | ||
use turbopack_core::chunk::ChunkingContext; | ||
|
||
use super::AstPath; | ||
use crate::{ | ||
code_gen::{CodeGenerateable, CodeGeneration}, | ||
create_visitor, | ||
}; | ||
|
||
#[turbo_tasks::value] | ||
pub struct IdentReplacement { | ||
value: RcStr, | ||
path: Vc<AstPath>, | ||
} | ||
|
||
#[turbo_tasks::value_impl] | ||
impl IdentReplacement { | ||
#[turbo_tasks::function] | ||
pub fn new(value: RcStr, path: Vc<AstPath>) -> Vc<Self> { | ||
Self::cell(IdentReplacement { value, path }) | ||
} | ||
} | ||
|
||
#[turbo_tasks::value_impl] | ||
impl CodeGenerateable for IdentReplacement { | ||
#[turbo_tasks::function] | ||
async fn code_generation( | ||
&self, | ||
_context: Vc<Box<dyn ChunkingContext>>, | ||
) -> Result<Vc<CodeGeneration>> { | ||
let value = self.value.clone(); | ||
let path = &self.path.await?; | ||
|
||
let visitor = create_visitor!(path, visit_mut_expr(expr: &mut Expr) { | ||
let id = Expr::Ident((&*value).into()); | ||
*expr = quote!("(\"TURBOPACK ident replacement\", $e)" as Expr, e: Expr = id); | ||
}); | ||
|
||
Ok(CodeGeneration::visitors(vec![visitor])) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
declare const __turbopack_external_require__: (id: string) => any; | ||
declare const __turbopack_external_require__: (id: string, thunk: () => any, esm?: boolean) => any; | ||
|
||
declare module "TESTS"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.