Skip to content

Commit 1d608ef

Browse files
committed
release: 0.0.9
1 parent dfab256 commit 1d608ef

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
1212
[dependencies]
1313
napi = "2"
1414
napi-derive = "2"
15-
nodejs-resolver = "0.0.18"
15+
nodejs-resolver = "0.0.19"
1616
serde = { version = "1.0.137", features = ["derive"] }
1717

1818
[build-dependencies]

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface RawResolverOptions {
2020
aliasFields?: Array<string>
2121
conditionNames?: Array<string>
2222
symlinks?: boolean
23-
descriptionFile?: string
23+
descriptionFile?: string | undefined | null
2424
mainFiles?: Array<string>
2525
mainFields?: Array<string>
2626
modules?: Array<string>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodejs-resolver",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "node binding for nodejs-resolver",
55
"main": "index.js",
66
"license": "MIT",

src/lib.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use napi::bindgen_prelude::External;
22
use napi_derive::napi;
33
use nodejs_resolver::{AliasMap, Resolver, ResolverOptions};
44
use serde::Deserialize;
5-
use std::path::{Path, PathBuf};
5+
use std::{
6+
path::{Path, PathBuf},
7+
};
68

79
#[derive(Debug, Clone, Deserialize)]
810
#[serde(rename_all = "camelCase")]
@@ -22,7 +24,7 @@ pub struct RawResolverOptions {
2224
pub alias_fields: Option<Vec<String>>,
2325
pub condition_names: Option<Vec<String>>,
2426
pub symlinks: Option<bool>,
25-
pub description_file: Option<String>,
27+
pub description_file: Option<Option<String>>,
2628
pub main_files: Option<Vec<String>>,
2729
pub main_fields: Option<Vec<String>>,
2830
pub modules: Option<Vec<String>>,
@@ -37,28 +39,25 @@ impl RawResolverOptions {
3739
ResolverOptions {
3840
enforce_extension: self.enforce_extension.to_owned(),
3941
extensions: self.extensions.to_owned().unwrap_or(default.extensions),
40-
alias: self
41-
.alias
42-
.to_owned()
43-
.map_or(default.alias, parse_alias),
42+
alias: self.alias.to_owned().map_or(default.alias, parse_alias),
4443
alias_fields: self.alias_fields.to_owned().unwrap_or(default.alias_fields),
4544
condition_names: self
4645
.condition_names
4746
.to_owned()
4847
.map_or(default.condition_names, |vec| vec.into_iter().collect()),
4948
symlinks: self.symlinks.unwrap_or(default.symlinks),
50-
description_file: self.description_file.to_owned(),
49+
description_file: self
50+
.description_file
51+
.to_owned()
52+
.unwrap_or(default.description_file),
5153
main_files: self.main_files.to_owned().unwrap_or(default.main_files),
5254
main_fields: self.main_fields.to_owned().unwrap_or(default.main_fields),
5355
prefer_relative: self.prefer_relative.unwrap_or(default.prefer_relative),
5456
enable_unsafe_cache: self
5557
.enable_unsafe_cache
5658
.to_owned()
5759
.unwrap_or(default.enable_unsafe_cache),
58-
tsconfig: self
59-
.tsconfig_path
60-
.to_owned()
61-
.map(PathBuf::from),
60+
tsconfig: self.tsconfig_path.to_owned().map(PathBuf::from),
6261
}
6362
}
6463
}
@@ -69,9 +68,7 @@ fn parse_alias(alias: Vec<Alias>) -> Vec<(String, AliasMap)> {
6968
.map(|item| {
7069
(
7170
item.key,
72-
item
73-
.value
74-
.map_or(AliasMap::Ignored, AliasMap::Target),
71+
item.value.map_or(AliasMap::Ignored, AliasMap::Target),
7572
)
7673
})
7774
.collect()
@@ -82,7 +79,8 @@ pub struct ResolverInternal {}
8279

8380
#[napi(ts_return_type = "ExternalObject<ResolverInternal>")]
8481
pub fn create(options: RawResolverOptions) -> Result<External<Resolver>, napi::Error> {
85-
let resolver = Resolver::new(options.normalized());
82+
let options = options.normalized();
83+
let resolver = Resolver::new(options);
8684
Ok(External::new(resolver))
8785
}
8886

0 commit comments

Comments
 (0)