-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: missing define_variable for export declarations #6012
Conversation
✅ Deploy Preview for rspack ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thank you! |
@@ -30,7 +30,7 @@ impl<'parser> JavascriptParser<'parser> { | |||
} | |||
ModuleDecl::ExportNamed(decl) => self.block_pre_walk_export_name_declaration(decl), | |||
ModuleDecl::ExportDefaultExpr(_) => (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems export default function Mod() {}
will have the same problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems
export default function Mod() {}
will have the same problem?
ExportDefaultDeclaration
case is covered here:
rspack/crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk_block_pre.rs
Lines 28 to 30 in ffd46f0
ModuleDecl::ExportDefaultDecl(decl) => { | |
self.block_pre_walk_export_default_declaration(decl) | |
} |
rspack/crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk_block_pre.rs
Lines 93 to 123 in ffd46f0
fn block_pre_walk_export_default_declaration(&mut self, decl: &ExportDefaultDecl) { | |
// FIXME: webpack use `self.pre_walk_statement(decl.decl)` | |
match &decl.decl { | |
DefaultDecl::Class(expr) => { | |
if let Some(ident) = &expr.ident { | |
self.define_variable(ident.sym.to_string()) | |
} | |
} | |
DefaultDecl::Fn(expr) => { | |
if let Some(ident) = &expr.ident { | |
self.define_variable(ident.sym.to_string()) | |
} | |
} | |
DefaultDecl::TsInterfaceDecl(_) => unreachable!(), | |
} | |
// FIXME: webpack use `self.block_pre_walk_statement(decl.decl)` | |
// match &decl.decl { | |
// DefaultDecl::Class(expr) => { | |
// if let Some(ident) = &expr.ident { | |
// self.define_variable(ident.sym.to_string()) | |
// } | |
// } | |
// DefaultDecl::Fn(expr) => { | |
// if let Some(ident) = &expr.ident { | |
// self.define_variable(ident.sym.to_string()) | |
// } | |
// } | |
// DefaultDecl::TsInterfaceDecl(_) => unreachable!(), | |
// } | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test case added: #6024
Summary
fixes: #5994
Require Documentation?