Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 12, 2023
1 parent e5217d4 commit 65679c2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion napi/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/node_modules/
*.node
target/
1 change: 0 additions & 1 deletion napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "oxc_napi_resolver"
version = "0.0.0"
publish = false


[lib]
crate-type = ["cdylib"]
test = false
Expand Down
4 changes: 3 additions & 1 deletion napi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
extern crate napi;
extern crate napi_derive;
extern crate oxc_resolver;

use std::path::{Path, PathBuf};

use napi_derive::napi;
mod options;
use oxc_resolver::{ResolveOptions, Resolver};

use self::options::NapiResolveOptions;

mod options;

#[napi(object)]
pub struct ResolveResult {
pub path: Option<String>,
Expand Down
10 changes: 0 additions & 10 deletions napi/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ pub struct Restriction {
/// Tsconfig Options
///
/// Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options)
#[napi(object)]
#[derive(Debug, Clone)]
pub struct TsconfigOptions {
Expand All @@ -189,15 +188,6 @@ pub struct TsconfigOptions {
pub references: Either<String, Vec<String>>,
}

// #[derive(Debug, Clone)]
// pub enum TsconfigReferences {
// Disabled,
// /// Use the `references` field from tsconfig read from `config_file`.
// Auto,
// /// Manually provided relative or absolute path.
// Paths(Vec<String>),
// }

impl Into<oxc_resolver::Restriction> for Restriction {
fn into(self) -> oxc_resolver::Restriction {
match (self.path, self.regex) {
Expand Down
4 changes: 2 additions & 2 deletions napi/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ assert.strict(resolver.sync(cwd, "./ts").error.length > 0);
// custom constructor
const resolver2 = new ResolverFactory(
{
extensions: ['.js', '.ts', '.node']
extensions: ['.mjs']
}
);

// After add `.ts` extension, resolver can resolve `ts` as `ts.ts` now
assert.deepStrictEqual(resolver2.sync(cwd, "./ts").path, path.join(cwd, 'ts.ts'));
assert.deepStrictEqual(resolver2.sync(cwd, "./test.mjs").path, path.join(cwd, 'test.mjs'));

0 comments on commit 65679c2

Please sign in to comment.