Download next.js/turbopack/crates/turbopack-ecmascript/src/annotations.rs from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/turbopack/crates/turbopack-ecmascript/src/annotations.rs
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/turbopack/crates/turbopack-ecmascript/src/annotations.rs
-
curl -L -o annotations.rs https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/turbopack/crates/turbopack-ecmascript/src/annotations.rs
1.1 kB
| use swc_core::{ | |
| common::DUMMY_SP, | |
| ecma::ast::{Expr, KeyValueProp, ObjectLit, Prop, PropName, PropOrSpread}, | |
| }; | |
| /// Changes the chunking type for the annotated import | |
| pub const ANNOTATION_CHUNKING_TYPE: &str = "turbopack-chunking-type"; | |
| /// Enables a specified transition for the annotated import | |
| pub const ANNOTATION_TRANSITION: &str = "turbopack-transition"; | |
| pub fn with_chunking_type(chunking_type: &str) -> Box<ObjectLit> { | |
| with_clause(&[(ANNOTATION_CHUNKING_TYPE, chunking_type)]) | |
| } | |
| pub fn with_transition(transition_name: &str) -> Box<ObjectLit> { | |
| with_clause(&[(ANNOTATION_TRANSITION, transition_name)]) | |
| } | |
| pub fn with_clause<'a>( | |
| entries: impl IntoIterator<Item = &'a (&'a str, &'a str)>, | |
| ) -> Box<ObjectLit> { | |
| Box::new(ObjectLit { | |
| span: DUMMY_SP, | |
| props: entries.into_iter().map(|(k, v)| with_prop(k, v)).collect(), | |
| }) | |
| } | |
| fn with_prop(key: &str, value: &str) -> PropOrSpread { | |
| PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { | |
| key: PropName::Str(key.into()), | |
| value: Box::new(Expr::Lit(value.into())), | |
| }))) | |
| } | |