Skip to content

Commit

Permalink
WIP: lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Oct 13, 2023
1 parent 43c0a8c commit 960d931
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
48 changes: 43 additions & 5 deletions crates/turbopack-css/src/lifetime_util.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
use lightningcss::{rules::import::ImportRule, stylesheet::StyleSheet};
use lightningcss::{
rules::{import::ImportRule, CssRule, CssRuleList},
stylesheet::StyleSheet,
};

pub fn stylesheet_into_static<'i, 'o>(_ss: &StyleSheet) -> StyleSheet<'i, 'o> {
todo!()
pub fn stylesheet_into_static<'i, 'o>(ss: &StyleSheet) -> StyleSheet<'i, 'o> {
let sources = ss.sources.clone();

let rules = CssRuleList(
ss.rules
.0
.into_iter()
.map(|rule| css_rule_to_static(&rule))
.collect(),
);

let options = ss.options.clone();

StyleSheet::new(sources, rules, options)
}

pub fn import_rule_to_static<'i>(_i: &ImportRule) -> ImportRule<'i> {
todo!()
fn css_rule_to_static<'i>(r: &CssRule) -> CssRule<'i> {
match r {
CssRule::Media(r) => {}
CssRule::Import(r) => CssRule::Import(r.clone().into_owned()),
CssRule::Style(r) => {}
CssRule::Keyframes(r) => {}
CssRule::FontFace(r) => {}
CssRule::FontPaletteValues(r) => {}
CssRule::Page(r) => {}
CssRule::Supports(r) => {}
CssRule::CounterStyle(r) => {}
CssRule::Namespace(r) => {}
CssRule::MozDocument(r) => {}
CssRule::Nesting(r) => {}
CssRule::Viewport(r) => {}
CssRule::CustomMedia(r) => {}
CssRule::LayerStatement(r) => {}
CssRule::LayerBlock(r) => {}
CssRule::Property(r) => {}
CssRule::Container(r) => {}
CssRule::StartingStyle(r) => {}
CssRule::Ignored => todo!(),
CssRule::Unknown(r) => {}
CssRule::Custom(r) => {}
}
}
2 changes: 1 addition & 1 deletion crates/turbopack-css/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<'a> Visitor<'_> for ModuleReferencesVisitor<'a> {
self.references.push(Vc::upcast(ImportAssetReference::new(
self.origin,
Request::parse(Value::new(src.to_string().into())),
ImportAttributes::new_from_prelude(&import_rule_to_static(i)).into(),
ImportAttributes::new_from_prelude(&i.clone().into_owned()).into(),
IssueSource::new(
Vc::upcast(self.source),
SourcePos {
Expand Down

0 comments on commit 960d931

Please sign in to comment.