Skip to content

Commit

Permalink
feat: add expreriental.keep_unresolved_node_require
Browse files Browse the repository at this point in the history
  • Loading branch information
xusd320 committed Nov 12, 2024
1 parent 4a4ff7e commit 2a9383a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/mako/src/config/experimental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::create_deserialize_fn;
pub struct ExperimentalConfig {
pub webpack_syntax_validate: Vec<String>,
pub require_context: bool,
// this feature is conflicting with require_context
pub keep_unresolved_node_require: bool,
pub magic_comment: bool,
#[serde(deserialize_with = "deserialize_detect_loop")]
pub detect_circular_dependence: Option<DetectCircularDependence>,
Expand Down
1 change: 1 addition & 0 deletions crates/mako/src/config/mako.config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"experimental": {
"webpackSyntaxValidate": [],
"requireContext": true,
"keepUnresolvedNodeRequire": false,
"magicComment": true,
"detectCircularDependence": {
"ignores": ["node_modules"],
Expand Down
8 changes: 7 additions & 1 deletion crates/mako/src/visitors/mako_require.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ impl VisitMut for MakoRequire {
}

fn visit_mut_ident(&mut self, ident: &mut Ident) {
if let Platform::Node = self.context.config.platform {
if self
.context
.config
.experimental
.keep_unresolved_node_require
&& let Platform::Node = self.context.config.platform

Check warning on line 57 in crates/mako/src/visitors/mako_require.rs

View check run for this annotation

Codecov / codecov/patch

crates/mako/src/visitors/mako_require.rs#L57

Added line #L57 was not covered by tests
{
return;
}
self.replace_require(ident);
Expand Down

0 comments on commit 2a9383a

Please sign in to comment.