Skip to content

Commit 15916d5

Browse files
committed
feat: CSS module graph
1 parent d91a51f commit 15916d5

File tree

41 files changed

+735
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+735
-208
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::{AnyCssImportUrl, AnyCssUrlValue};
2+
use biome_rowan::TokenText;
3+
4+
impl AnyCssImportUrl {
5+
/// Returns the inner text of specifier:
6+
///
7+
/// ## Examples
8+
///
9+
/// ```
10+
/// use biome_css_factory::make;
11+
/// use biome_css_syntax::AnyCssImportUrl;
12+
/// ```
13+
pub fn inner_string_text(&self) -> Option<TokenText> {
14+
match self {
15+
Self::CssString(css) => css.inner_string_text().ok(),
16+
Self::CssUrlFunction(url_function) => {
17+
url_function.value().and_then(|value| match value {
18+
AnyCssUrlValue::CssString(css) => css.inner_string_text().ok(),
19+
AnyCssUrlValue::CssUrlValueRaw(raw) => raw
20+
.value_token()
21+
.ok()
22+
.map(|token| token.token_text_trimmed()),
23+
})
24+
}
25+
}
26+
}
27+
}

crates/biome_css_syntax/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#[macro_use]
44
mod file_source;
55
mod generated;
6+
mod import_ext;
67
pub mod selector_ext;
78
pub mod stmt_ext;
89
mod string_ext;

crates/biome_js_analyze/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ where
159159
.map(|(path, manifest)| (path, Arc::new(manifest)));
160160

161161
let type_resolver = module_graph
162-
.module_info_for_path(file_path.as_ref())
162+
.js_module_info_for_path(file_path.as_ref())
163163
.map(|module_info| ModuleResolver::for_module(module_info, module_graph.clone()))
164164
.map(Arc::new);
165165

crates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn get_deprecated_imports_from_module_source(
125125
target_path: &Utf8Path,
126126
module_graph: &ModuleGraph,
127127
) -> Vec<NoDeprecatedImportsState> {
128-
let Some(module_info) = module_graph.module_info_for_path(target_path) else {
128+
let Some(module_info) = module_graph.js_module_info_for_path(target_path) else {
129129
return Vec::new();
130130
};
131131

crates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,6 @@ fn get_unresolved_imports_from_module_source(
260260
fn has_exported_symbol(import_name: &Text, options: &GetUnresolvedImportsOptions) -> bool {
261261
options
262262
.target_info
263-
.find_exported_symbol(options.module_graph, import_name.text())
263+
.find_js_exported_symbol(options.module_graph, import_name.text())
264264
.is_some()
265265
}

crates/biome_js_analyze/src/services/module_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl ModuleGraphService {
1717
}
1818

1919
pub fn module_info_for_path(&self, path: &Utf8Path) -> Option<JsModuleInfo> {
20-
self.0.module_info_for_path(path)
20+
self.0.js_module_info_for_path(path)
2121
}
2222

2323
pub fn project_layout(&self) -> &ProjectLayout {

crates/biome_lsp/src/server.tests.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,7 +3838,11 @@ async fn should_open_and_update_nested_files() -> Result<()> {
38383838
result
38393839
.data
38403840
.get(fs.working_directory.join("src").join("a.js").as_str())
3841-
.map(|module_info| module_info.static_import_paths.clone()),
3841+
.map(|module_info| module_info
3842+
.as_js_module_info()
3843+
.unwrap()
3844+
.static_import_paths
3845+
.clone()),
38423846
Some(BTreeMap::from([("foo".to_string(), "foo".to_string())]))
38433847
);
38443848

@@ -3865,7 +3869,11 @@ async fn should_open_and_update_nested_files() -> Result<()> {
38653869
result
38663870
.data
38673871
.get(fs.working_directory.join("src").join("a.js").as_str())
3868-
.map(|module_info| module_info.static_import_paths.clone()),
3872+
.map(|module_info| module_info
3873+
.as_js_module_info()
3874+
.unwrap()
3875+
.static_import_paths
3876+
.clone()),
38693877
Some(BTreeMap::from([("bar".to_string(), "bar".to_string())]))
38703878
);
38713879

crates/biome_module_graph/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ workspace = true
1616

1717
[dependencies]
1818
biome_console = { workspace = true }
19+
biome_css_semantic = { workspace = true }
20+
biome_css_syntax = { workspace = true }
1921
biome_diagnostics = { workspace = true }
2022
biome_formatter = { workspace = true }
2123
biome_fs = { workspace = true }

crates/biome_module_graph/benches/module_graph.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ fn bench_index_d_ts(bencher: Bencher, name: &str) {
7373
&fs,
7474
&ProjectLayout::default(),
7575
&[(&path, root)],
76-
&[],
7776
);
7877
divan::black_box(&module_graph);
7978
});

0 commit comments

Comments
 (0)