Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit d7b79e3

Browse files
committed
Fix css resolving
1 parent bb18ee6 commit d7b79e3

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

compiler/src/resolver.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use import_map::ImportMap;
2-
use indexmap::IndexSet;
32
use path_slash::PathBufExt;
43
use pathdiff::diff_paths;
54
use regex::Regex;
@@ -39,8 +38,6 @@ pub struct Resolver {
3938
pub deps: Vec<DependencyDescriptor>,
4039
/// jsx runtime: react | preact
4140
pub jsx_runtime: Option<String>,
42-
/// jsx static class names
43-
pub jsx_static_classes: IndexSet<String>,
4441
/// development mode
4542
pub is_dev: bool,
4643
// internal
@@ -81,7 +78,6 @@ impl Resolver {
8178
jsx_runtime,
8279
jsx_runtime_version,
8380
jsx_runtime_cdn_version,
84-
jsx_static_classes: IndexSet::new(),
8581
import_map,
8682
graph_versions,
8783
initial_graph_version,
@@ -112,15 +108,7 @@ impl Resolver {
112108
}
113109
}
114110
local_path.push_str(pathname.to_owned().to_slash().unwrap().as_str());
115-
if is_css_url(url.path()) {
116-
if let Some(query) = url.query() {
117-
local_path.push('?');
118-
local_path.push_str(query);
119-
local_path.push_str("&module");
120-
} else {
121-
local_path.push_str("?module");
122-
}
123-
} else if let Some(query) = url.query() {
111+
if let Some(query) = url.query() {
124112
local_path.push('?');
125113
local_path.push_str(query);
126114
}
@@ -249,14 +237,14 @@ impl Resolver {
249237
}
250238
}
251239

252-
pub fn is_esm_sh_url(url: &str) -> bool {
253-
return url.starts_with("https://esm.sh/") || url.starts_with("http://esm.sh/");
254-
}
255-
256240
pub fn is_http_url(url: &str) -> bool {
257241
return url.starts_with("https://") || url.starts_with("http://");
258242
}
259243

244+
pub fn is_esm_sh_url(url: &str) -> bool {
245+
return url.starts_with("https://esm.sh/") || url.starts_with("http://esm.sh/");
246+
}
247+
260248
pub fn is_css_url(url: &str) -> bool {
261249
if is_esm_sh_url(url) {
262250
let url = Url::from_str(url).unwrap();
@@ -267,7 +255,7 @@ pub fn is_css_url(url: &str) -> bool {
267255
}
268256
return false;
269257
}
270-
return url.ends_with(".css") || url.starts_with(".pcss") || url.starts_with(".postcss");
258+
return url.ends_with(".css") || url.contains(".css?");
271259
}
272260

273261
fn is_false(value: &bool) -> bool {

compiler/src/swc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl SWC {
201201
Optional::new(hmr(resolver.clone()), is_dev && !specifier_is_remote),
202202
fixer(Some(&self.comments)),
203203
hygiene()
204-
);
204+
);
205205

206206
let (code, map) = self.emit(passes, options.source_map, options.minify).unwrap();
207207

0 commit comments

Comments
 (0)