Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Jan 26, 2025
1 parent 217a9bc commit 418a824
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ wax = { version = "0.6", default-features = false, features = [
] }
globset = { version = "0.4.14" }
swc_ecma_ast = { version = "3.0.0", features = ["rkyv-impl", "serde-impl"] }
swc_typescript = { version = "3.0.0" }
swc_ecma_parser = { version = "4.0.0" }
swc_common = { version = "3.0.0", features = [
"concurrent",
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub use swc_css_ast;
pub use swc_ecma_ast;
pub use swc_ecma_parser;
pub use swc_html_ast;
pub use swc_typescript;
pub use wax;

// re-export common type alias
Expand Down
1 change: 1 addition & 0 deletions crates/toolkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ farmfe_testing_helpers = { path = "../testing_helpers", version = "0.0.15" }
swc_ecma_parser = { version = "4.0.0" }
swc_ecma_visit = { version = "3.0.0" }
swc_ecma_codegen = { version = "3.0.0" }
swc_typescript = { version = "3.0.0" }
swc_ecma_transforms = { version = "4.0.0", features = [
"module",
"typescript",
Expand Down
1 change: 1 addition & 0 deletions crates/toolkit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod script;
pub use preset_env_base;
pub use swc_ecma_codegen;
pub use swc_ecma_minifier;
pub use swc_typescript;
pub use swc_ecma_parser;
pub use swc_ecma_preset_env;
pub use swc_ecma_transforms;
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import type { base } from './test.ts';
export const a: number = 1;
import type { UserInfo } from '@/test2.ts';
// 我是奥特曼
export function b<T extends string>(name: string, userInfo: UserInfo): T {
export function b<T extends strin2222g>(name: string, userInfo: UserInfo): T {
return name + names + '123' as T;
}
29 changes: 13 additions & 16 deletions rust-plugins/dts/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![deny(clippy::all)]
use farmfe_core::{
config::{config_regex::ConfigRegex,ResolveConfig, Config},
config::{config_regex::ConfigRegex, Config, ResolveConfig},
context::{CompilationContext, EmitFileParams},
error::CompilationError,
plugin::{
Expand All @@ -13,7 +13,6 @@ use farmfe_core::{
swc_common::{comments::SingleThreadedComments, BytePos, FileName, Mark},
swc_ecma_ast::{ImportDecl, Module as EcmaAstModule, ModuleDecl, ModuleItem, Program},
swc_ecma_parser::{lexer::Lexer, EsSyntax as EsConfig, JscTarget, Parser, StringInput, Syntax},
swc_typescript::fast_dts::FastDts,
};
use farmfe_plugin_resolve::resolver::{ResolveOptions, Resolver};

Expand All @@ -22,6 +21,7 @@ use farmfe_toolkit::{
swc_ecma_codegen::{to_code, Node},
swc_ecma_transforms::{helpers::inject_helpers, typescript},
swc_ecma_visit::{VisitMut, VisitMutWith},
swc_typescript::fast_dts::FastDts,
};
use std::time::Duration;
use std::{
Expand Down Expand Up @@ -158,13 +158,12 @@ struct ImportPathRewriter {
resolver: Resolver,
}

// TODO 生成后缀
// TODO 生成后缀
// 主要依据:根据 Rollup 的 outputOptions.entryFileNames 配置
// 如果输出是 .js -> 生成 .d.ts
// 如果输出是 .cjs -> 生成 .d.cts
// 如果输出是 .mjs -> 生成 .d.mts


// {
// output: {
// entryFileNames: '[name].cjs' // 将生成 .d.cts
Expand All @@ -177,10 +176,9 @@ struct ImportPathRewriter {

// 然后这个先不跟 format 走吧 format 未来可能会有问题 还是跟 entryFileNames 走吧


// TODO emit_file baseDir
// extraOutdir
// 默认全放在根目录
// 默认全放在根目录

// 如果设置了 extraOutdir 则需要根据 extraOutdir 来生成后缀

Expand All @@ -189,15 +187,14 @@ impl VisitMut for ImportPathRewriter {
for item in items.iter_mut() {
if let ModuleItem::ModuleDecl(ModuleDecl::Import(import)) = item {
let src = &mut import.src;
let alias_context =
CompilationContext::new(
Config {
resolve: Box::new(ResolveConfig {
alias: self.config.resolve.alias.clone(),
..Default::default()
}),
..Default::default()
},
let alias_context = CompilationContext::new(
Config {
resolve: Box::new(ResolveConfig {
alias: self.config.resolve.alias.clone(),
..Default::default()
}),
..Default::default()
},
vec![],
)
.unwrap();
Expand All @@ -210,7 +207,7 @@ impl VisitMut for ImportPathRewriter {
);
if let Some(resolved_path) = resolved {
let path = PathBuf::from(resolved_path.resolved_path);

let base_path = path.with_extension("");
let final_value = base_path
.with_extension("d.ts")
Expand Down

0 comments on commit 418a824

Please sign in to comment.