diff --git a/fastn-resolved/src/web_component.rs b/fastn-resolved/src/web_component.rs index c5d5add2b..8d4fe2d8f 100644 --- a/fastn-resolved/src/web_component.rs +++ b/fastn-resolved/src/web_component.rs @@ -20,4 +20,14 @@ impl WebComponentDefinition { line_number, } } + + pub fn js(&self) -> Option<&str> { + match self.js { + fastn_resolved::PropertyValue::Value { ref value, .. } => match value { + fastn_resolved::Value::String { text } => Some(text), + _ => None, + }, + _ => None, + } + } } diff --git a/v0.5/fastn-compiler/src/utils.rs b/v0.5/fastn-compiler/src/utils.rs index 5bdeca505..c9cff1921 100644 --- a/v0.5/fastn-compiler/src/utils.rs +++ b/v0.5/fastn-compiler/src/utils.rs @@ -24,10 +24,17 @@ impl fastn_compiler::Compiler { pub(crate) fn external_js_files( &self, - _needed_symbols: &indexmap::IndexMap, + used_definitions: &indexmap::IndexMap, ) -> Vec { - // go through needed_symbols and get the external js files - todo!() + used_definitions + .values() + .filter_map(|definition| match definition { + fastn_resolved::Definition::WebComponent(web_component) => { + web_component.js().map(ToOwned::to_owned) + } + _ => None, + }) + .collect() } pub(crate) fn external_css_files(