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 finishMake hook #3390

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

dmitry-stepanenko
Copy link
Contributor

@dmitry-stepanenko dmitry-stepanenko commented Jun 1, 2023

Related issue (if exists)

#3158

Summary

Adds the afterCompile hook needed for ProgressPlugin.

🤖 Generated by Copilot at 5f4b7af

This pull request adds a new finishMake hook to the rspack compiler and its node binding. The hook allows plugins to run custom functions after the modules and dependencies are created. The pull request also adds a custom plugin example and a test case that use the hook to remove the hash from the output filenames. The pull request modifies several files in the crates and packages folders to implement and expose the hook.

Walkthrough

🤖 Generated by Copilot at 5f4b7af

  • Add a new variant FinishMake to the enum Hook that represents the types of hooks for plugins (link)
  • Add a new match arm to the from_str function that converts a string to a Hook variant for the FinishMake case (link)
  • Add a new field finish_make to the struct Hooks that holds the JavaScript functions registered as hooks by plugins (link)
  • Add a new field finish_make_tsfn to the struct Plugin that wraps the finish_make JavaScript function in a threadsafe function (link)
  • Add a new method finish_make to the struct Plugin that calls the finish_make_tsfn with the current compilation (link)
  • Add the finish_make JavaScript function to the list of arguments for the new function of the struct Plugin (link)
  • Initialize the finish_make_tsfn field with the js_fn_into_theadsafe_fn! macro in the new function of the struct Plugin (link)
  • Add the finish_make_tsfn field to the return value of the new function of the struct Plugin (link)
  • Add a new line to the compile method of the struct Compiler in crates/rspack_core/src/compiler/mod.rs that calls the finish_make method of the plugin_driver after the make method and before the after_compile method (link)
  • Add a new method finish_make to the trait PluginAPI that takes a mutable reference to a Compilation and returns a Result<()> (link)
  • Add a new method finish_make to the struct PluginDriver that iterates over the plugins and calls their finish_make methods with the current compilation (link)
  • Add a new file examples/basic/rspack.config.js that contains a custom plugin class RemoveHashPlugin that demonstrates the usage of the finishMake hook (link)
  • Add a new property plugins to the config object in examples/basic/rspack.config.js that contains an instance of the RemoveHashPlugin class (link)
  • Add a new property finishMake to the class Compiler in packages/rspack/src/compiler.ts that is an instance of the tapable.AsyncSeriesHook class that represents the finishMake hook (link)
  • Initialize the finishMake property with a new instance of the tapable.AsyncSeriesHook class in the constructor of the class Compiler in packages/rspack/src/compiler.ts (link)
  • Add a new property finishMake to the object that is returned by the getHooks method of the class Compiler in packages/rspack/src/compiler.ts that is assigned the value of the #finishMake private method of the class (link)
  • Add a new property finishMake to the object that is passed to the createCompiler function in packages/rspack/src/compiler.ts that is assigned the value of the finishMake property of the hooks object (link)
  • Add a new private method #finishMake to the class Compiler in packages/rspack/src/compiler.ts that calls the finishMake hook with the current compilation and updates the list of disabled hooks (link)
  • Add a new file packages/rspack/tests/configCases/hooks/compilation-hooks/a.js that contains a simple export statement and is used as a dependency by the index.js file in the same folder (link)
  • Add a new file packages/rspack/tests/configCases/hooks/compilation-hooks/index.js that contains a simple import statement and a test case that verifies the finishMake hook (link)
  • Add a new file packages/rspack/tests/configCases/hooks/compilation-hooks/webpack.config.js that contains the configuration options for the test case that verifies the finishMake hook (link)

@CLAassistant
Copy link

CLAassistant commented Jun 1, 2023

CLA assistant check
All committers have signed the CLA.

@dmitry-stepanenko dmitry-stepanenko force-pushed the ds/finish-make-hook branch 3 times, most recently from 991ea7d to 6a25e1e Compare June 2, 2023 05:11
@h-a-n-a h-a-n-a added this pull request to the merge queue Jun 2, 2023
Merged via the queue into web-infra-dev:main with commit 231404e Jun 2, 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.

3 participants