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

feat: add afterCompile hook #3235

Merged
merged 1 commit into from
May 22, 2023

Conversation

edusperoni
Copy link
Contributor

@edusperoni edusperoni commented May 19, 2023

Related issue (if exists)

#3158

Summary

Adds the afterCompile hook needed for ProgressPlugin.

🤖 Generated by Copilot at 13aa843

This pull request adds a new hook afterCompile to the compiler and the plugin system. The hook allows plugins to run custom code after the compilation is done and before the output is emitted. The pull request modifies several files in the crates and packages directories to implement and support this new hook.

Walkthrough

🤖 Generated by Copilot at 13aa843

  • Add a new hook afterCompile to the plugin system that allows plugins to perform custom logic after the compilation is done and before the output is emitted (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Define a new variant Hook::AfterCompile in crates/node_binding/src/hook.rs and handle its conversion from a string (link, link)
  • Add a new field after_compile to the Hooks struct in crates/node_binding/src/js_values/hooks.rs that holds the JavaScript function for the hook (link)
  • Add a new field after_compile_tsfn to the Plugin struct in crates/node_binding/src/plugins/mod.rs that wraps the JavaScript function in a ThreadsafeFunction (link)
  • Add a new method after_compile to the Plugin struct in crates/node_binding/src/plugins/mod.rs that calls the after_compile_tsfn with the current Compilation object (link)
  • Export the after_compile method from the Plugin struct in crates/node_binding/src/plugins/mod.rs and create a ThreadsafeFunction from the after_compile JavaScript function in the init and new methods (link, link, link)
  • Call the after_compile method of the plugin_driver in the compile method of the Compiler struct in crates/rspack_core/src/compiler/mod.rs (link)
  • Add a default implementation of the after_compile method to the Plugin trait in crates/rspack_core/src/plugin/api.rs (link)
  • Add a new method after_compile to the PluginDriver struct in crates/rspack_core/src/plugin/plugin_driver.rs that iterates over the plugins and calls their after_compile methods (link)
  • Add a new property afterCompile to the Compiler class in packages/rspack/src/compiler.ts that is an instance of the tapable.AsyncSeriesHook class (link)
  • Initialize the afterCompile property of the Compiler class in packages/rspack/src/compiler.ts and pass it to the Rust Compiler struct in the createCompiler function (link, link)
  • Return the afterCompile property from the getHooks method of the Compiler class in packages/rspack/src/compiler.ts and add a private method #afterCompile that invokes the hook and updates the list of disabled hooks (link, link)

@hardfist hardfist added this pull request to the merge queue May 22, 2023
Merged via the queue into web-infra-dev:main with commit d32c3ae May 22, 2023
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

Successfully merging this pull request may close these issues.

2 participants