-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
241 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
edition = "2018" | ||
format_strings = true | ||
group_imports = "StdExternalCrate" | ||
hex_literal_case = "Lower" | ||
imports_granularity = "Crate" | ||
reorder_impl_items = true | ||
use_field_init_shorthand = true | ||
wrap_comments = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cognitive-complexity-threshold = 50 | ||
disallowed-names = [ | ||
"bool", | ||
"char", | ||
"str", | ||
"f32", | ||
"f64", | ||
"i8", | ||
"i16", | ||
"i32", | ||
"i64", | ||
"u8", | ||
"u16", | ||
"u32", | ||
"u64", | ||
"isize", | ||
"usize", | ||
] | ||
ignore-interior-mutability = [ | ||
"bytes::Bytes", | ||
"swc_atoms::Atom", | ||
"swc_atoms::JsWord", | ||
"swc_ecma_ast::Id", | ||
] | ||
msrv = "1.70" | ||
type-complexity-threshold = 25000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
*.wasm | ||
.swcrc | ||
.swc | ||
*.d.ts | ||
auto-import.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! https://rspack.dev/api/runtime-api/hmr | ||
//! 为 HMR 添加一些特殊的转换 | ||
use swc_core::{ | ||
ecma::visit::{noop_visit_mut_type, VisitMut, VisitMutWith}, | ||
quote, | ||
}; | ||
use swc_ecma_ast::ModuleItem; | ||
|
||
#[derive(Default)] | ||
struct TransformVisitor {} | ||
|
||
impl VisitMut for TransformVisitor { | ||
noop_visit_mut_type!(); | ||
|
||
fn visit_mut_module_items(&mut self, node: &mut Vec<ModuleItem>) { | ||
node.visit_mut_children_with(self); | ||
|
||
node.push(quote!( | ||
" | ||
if (module.hot) { | ||
module.hot.accept(); | ||
} | ||
" as ModuleItem, | ||
)); | ||
} | ||
} | ||
|
||
pub fn hmr_transform() -> impl VisitMut { | ||
TransformVisitor::default() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod hmr; | ||
pub mod import; | ||
pub mod memo; | ||
pub mod minify; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.