Skip to content

Commit

Permalink
Support member as
Browse files Browse the repository at this point in the history
  • Loading branch information
mantou132 committed Dec 10, 2024
1 parent b321383 commit dfafcf1
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 139 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ indexmap = { version = "2.6.0" }
regex = { version = "1.10.4", default-features = false }
serde = "1.0.203"
serde_json = "1.0.117"
serde_regex = "1.1.0"
swc_core = "5.0.0"
swc_ecma_parser = "5.0.0"
swc_ecma_visit = "4.0.0"
Expand Down
6 changes: 5 additions & 1 deletion crates/swc-plugin-gem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ lto = true
node-resolve = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
swc_core = { workspace = true, features = ["ecma_quote", "ecma_plugin_transform"] }
serde_regex = { workspace = true }
swc_core = { workspace = true, features = [
"ecma_quote",
"ecma_plugin_transform",
] }
swc_ecma_visit = { workspace = true }
swc_common = { workspace = true, features = ["concurrent"] }
swc_ecma_ast = { workspace = true }
Expand Down
11 changes: 6 additions & 5 deletions crates/swc-plugin-gem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use swc_core::{
use swc_ecma_ast::Program;
pub use visitors::{
hmr::hmr_transform,
import::{import_transform, AutoImport},
import::{import_transform, AutoImport, AutoImportContent, AutoImportDts, MemberOrMemberAs},
memo::memo_transform,
minify::minify_transform,
path::path_transform,
Expand All @@ -23,12 +23,13 @@ mod visitors;
#[serde(default, rename_all = "camelCase")]
struct PluginConfig {
pub style_minify: bool,
/// e.g: https://github.com/mantou132/gem/blob/main/crates/swc-plugin-gem/README.md#example
pub auto_import: AutoImport,
/// Write into the src directory
pub auto_import_dts: bool,
/// Generate .d.ts file, use src/auto-import.d.ts when true
pub auto_import_dts: AutoImportDts,
/// Use esm directly with import map
pub resolve_path: bool,
///depend on URL loader, top await
///depend on URL loader & top await
pub preload: bool,
/// Under development, need add `@mantou/gem/helper/hmr` to entry
pub hmr: bool,
Expand All @@ -55,7 +56,7 @@ pub fn process_transform(mut program: Program, data: TransformPluginProgramMetad
Optional {
enabled: match config.auto_import {
AutoImport::Gem(enabled) => enabled,
AutoImport::Custom(_) => true,
AutoImport::CustomContent(_) => true,
},
visitor: import_transform(config.auto_import, config.auto_import_dts),
},
Expand Down
Loading

0 comments on commit dfafcf1

Please sign in to comment.