Skip to content
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

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

xc2
Copy link
Collaborator

@xc2 xc2 commented Mar 22, 2024

Summary

fixes: #5994

Require Documentation?

  • No
  • Yes, the corresponding rspack-website PR is __

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Mar 22, 2024
Copy link

netlify bot commented Mar 22, 2024

Deploy Preview for rspack ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 40f3d73
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/65fdb85abb162000089221d1
😎 Deploy Preview https://deploy-preview-6012--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@xc2 xc2 requested a review from ahabhgk March 22, 2024 17:43
@h-a-n-a
Copy link
Collaborator

h-a-n-a commented Mar 23, 2024

Thank you!

@@ -30,7 +30,7 @@ impl<'parser> JavascriptParser<'parser> {
}
ModuleDecl::ExportNamed(decl) => self.block_pre_walk_export_name_declaration(decl),
ModuleDecl::ExportDefaultExpr(_) => (),
Copy link
Collaborator

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?

Copy link
Collaborator Author

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:

ModuleDecl::ExportDefaultDecl(decl) => {
self.block_pre_walk_export_default_declaration(decl)
}

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!(),
// }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case added: #6024

@ahabhgk ahabhgk enabled auto-merge (squash) March 25, 2024 03:35
@ahabhgk ahabhgk merged commit cfe4cee into web-infra-dev:main Mar 25, 2024
39 checks passed
@xc2 xc2 deleted the fix/5994 branch March 25, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: bug fix release: bug related release(mr only)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Using ProvidePlugin causes duplicated identifiers
3 participants