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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document webpack change: support destructuring assignment in parser #6755

Closed
webpack-bot opened this issue Apr 12, 2023 · 1 comment
Closed

Comments

@webpack-bot
Copy link

A pull request by @vankop was merged and maintainers requested a documentation change.

See pull request: webpack/webpack#16941


related to webpack/webpack#14800

TODO

Other features like async/await could be added in another PR

Summary

馃 Generated by Copilot at 9bb35fb

This pull request enhances the DefinePlugin class to optimize the code generation for object expressions that are replaced by RuntimeValue instances. It also adds support for tracking the used keys of destructuring assignment expressions in object patterns, and updates the JavascriptParser class accordingly. It includes a new test case to verify the functionality of the DefinePlugin with RuntimeValue instances.

Details

馃 Generated by Copilot at 9bb35fb

  • Add a new parameter objKeys to the RuntimeValue class and its methods to optimize the code generation for object expressions (link, link, link, link, link, link)
  • Pass the objKeys parameter to the toCode function call in the DefinePlugin class, where it replaces expressions with RuntimeValue instances (link, link)
  • Obtain the objKeys parameter from the parser.destructuringAssignmentKeysFor method, which returns the set of used keys for a destructuring assignment expression (link, link)
  • Add a new property destructuringAssignmentKeys and a new method destructuringAssignmentKeysFor to the JavascriptParser class to store and retrieve the used keys for each destructuring assignment expression node (link, link)
  • Update the blockPreWalkStatements, preWalkStatements, and preWalkAssignmentExpression methods of the JavascriptParser class to handle expression statements, variable declarators, and assignment expressions with object patterns, and set the destructuringAssignmentKeys property accordingly (link, link, link, link)
  • Initialize and reset the destructuringAssignmentKeys property of the JavascriptParser class in the enterBlock and leaveBlock methods, which are called when entering and leaving a block scope (link, link)
  • Add a new test case to the define-plugin config case in test/configCases/plugins/define-plugin/index.js and test/configCases/plugins/define-plugin/webpack.config.js to check the functionality and optimization of the DefinePlugin with object expressions and destructuring assignments (link, link)
@chenxsan
Copy link
Member

This seems be a low-level changes, so nothing to document from what I can tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants