Skip to content

Commit

Permalink
fix: applying type change request and default function as part of struct
Browse files Browse the repository at this point in the history
  • Loading branch information
hanseltime committed Dec 9, 2024
1 parent a05963a commit 252afff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/swc/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ fn build_resolver(
mut base_url: PathBuf,
paths: CompiledPaths,
resolve_fully: bool,
file_extension: &String,
file_extension: &str,
) -> SwcImportResolver {
static CACHE: Lazy<DashMap<(PathBuf, CompiledPaths, bool), SwcImportResolver, ARandomState>> =
Lazy::new(Default::default);
Expand Down
4 changes: 1 addition & 3 deletions crates/swc_ecma_transforms_module/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ use swc_ecma_loader::resolve::{Resolution, Resolve};
use swc_ecma_utils::{quote_ident, ExprFactory};
use tracing::{debug, info, warn, Level};

use crate::util::default_js_ext;

#[derive(Default)]
pub enum Resolver {
Real {
Expand Down Expand Up @@ -108,7 +106,7 @@ pub struct Config {
impl Default for Config {
fn default() -> Config {
Config {
file_extension: default_js_ext(),
file_extension: crate::util::Config::default_js_ext(),
resolve_fully: bool::default(),
base_dir: Option::default(),
}
Expand Down
8 changes: 5 additions & 3 deletions crates/swc_ecma_transforms_module/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ pub struct Config {
#[serde(default)]
pub resolve_fully: bool,

#[serde(default = "default_js_ext")]
#[serde(default = "Config::default_js_ext")]
pub out_file_extension: String,
}

pub fn default_js_ext() -> String {
"js".to_string()
impl Config {
pub fn default_js_ext() -> String {
"js".to_string()
}
}

impl Default for Config {
Expand Down
3 changes: 1 addition & 2 deletions crates/swc_ecma_transforms_module/tests/path_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use swc_ecma_parser::Syntax;
use swc_ecma_transforms_module::{
path::{ImportResolver, NodeImportResolver},
rewriter::import_rewriter,
util::default_js_ext,
};
use swc_ecma_transforms_testing::{test_fixture, FixtureTestConfig};
use testing::run_test2;
Expand Down Expand Up @@ -107,7 +106,7 @@ fn paths_resolver(base_dir: &Path, rules: Vec<(String, Vec<String>)>) -> JscPath
swc_ecma_transforms_module::path::Config {
base_dir: Some(base_dir),
resolve_fully: true,
file_extension: default_js_ext(),
file_extension: swc_ecma_transforms_module::util::Config::default_js_ext(),
},
)
}
Expand Down

0 comments on commit 252afff

Please sign in to comment.