Skip to content

Commit

Permalink
feat: use oxc_resolver (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin authored Oct 7, 2023
1 parent 6f6dacc commit 79de1ad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 66 deletions.
77 changes: 21 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rolldown_resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.0.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
nodejs-resolver = "0.0.69"
oxc_resolver = "0.2.0"
sugar_path = { workspace = true }
anyhow = { workspace = true }
rolldown_error = { path = "../rolldown_error" }
Expand Down
15 changes: 6 additions & 9 deletions crates/rolldown_resolver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ use std::{
path::{Path, PathBuf},
};

use nodejs_resolver::{Options, Resolver as EnhancedResolver};
use oxc_resolver::{ResolveOptions, Resolver as OxcResolver};

#[derive(Debug)]
pub struct Resolver {
cwd: PathBuf,
inner: EnhancedResolver,
inner: OxcResolver,
}

impl Resolver {
pub fn with_cwd(cwd: PathBuf, preserve_symlinks: bool) -> Self {
Self {
cwd,
inner: EnhancedResolver::new(Options {
inner: OxcResolver::new(ResolveOptions {
symlinks: !preserve_symlinks,
extensions: vec![
".js".to_string(),
Expand Down Expand Up @@ -72,12 +72,9 @@ impl Resolver {
let resolved = self.inner.resolve(context, &specifier.to_string_lossy());

match resolved {
Ok(resolved) => match resolved {
nodejs_resolver::ResolveResult::Info(info) => Ok(ResolveRet {
resolved: info.path().to_string_lossy().to_string().into(),
}),
nodejs_resolver::ResolveResult::Ignored => unreachable!(),
},
Ok(info) => Ok(ResolveRet {
resolved: info.path().to_string_lossy().to_string().into(),
}),
Err(_err) => {
if let Some(importer) = importer {
Err(Box::new(RError::unresolved_import(
Expand Down

0 comments on commit 79de1ad

Please sign in to comment.