Skip to content

Commit 66c5e0d

Browse files
authored
revert: fix: align amd option behavior with webpack (#9103)
1 parent 9df4956 commit 66c5e0d

File tree

88 files changed

+218
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+218
-145
lines changed

β€Žcrates/rspack_plugin_javascript/src/parser_plugin/amd/amd_define_dependency_parser_plugin.rsβ€Ž

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@ impl AMDDefineDependencyParserPlugin {
289289
}
290290
} else {
291291
// define([…], …)
292-
if !first_arg.expr.is_array() {
293-
return None;
294-
}
295-
296292
array = Some(&first_arg.expr);
297293

298294
if is_callable(&second_arg.expr) {

β€Žcrates/rspack_plugin_javascript/src/parser_plugin/amd/amd_plugin.rsβ€Ž

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ impl JavascriptParserPlugin for AMDParserPlugin {
141141
None
142142
}
143143

144+
fn identifier(
145+
&self,
146+
parser: &mut JavascriptParser,
147+
ident: &swc_core::ecma::ast::Ident,
148+
for_name: &str,
149+
) -> Option<bool> {
150+
if for_name == DEFINE {
151+
parser
152+
.presentational_dependencies
153+
.push(Box::new(ConstDependency::new(
154+
ident.span().real_lo(),
155+
ident.span().real_hi(),
156+
RuntimeGlobals::AMD_DEFINE.name().into(),
157+
Some(RuntimeGlobals::AMD_DEFINE),
158+
)));
159+
return Some(true);
160+
}
161+
None
162+
}
163+
144164
fn evaluate_identifier(
145165
&self,
146166
_parser: &mut JavascriptParser,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import("@rspack/core").Configuration} */
2+
module.exports = {
3+
amd: {},
4+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import("@rspack/core").Configuration} */
2+
module.exports = {
3+
amd: {},
4+
};

0 commit comments

Comments
Β (0)