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 runtime plugin hooks #9084

Merged
merged 4 commits into from
Jan 23, 2025
Merged

feat: add runtime plugin hooks #9084

merged 4 commits into from
Jan 23, 2025

Conversation

LingyuCoder
Copy link
Contributor

@LingyuCoder LingyuCoder commented Jan 22, 2025

Summary

relate to #4381

Support RuntimePlugin.getCompilationHooks to modify the code which create script and link tags. Just like mainTemplate.jsonpScript/linkPrefetch/linkPreload in webpack

Cause load script runtime module is not only used in jsonp chunk loading, so rename jsonScript to its inner name createScript in webpack


This pull request introduces significant enhancements to the rspack project, primarily focusing on integrating new runtime plugin functionalities. The changes include adding new dependencies, expanding existing modules to support the new runtime plugins, and updating relevant hooks and structures to accommodate these additions.

Enhancements to Runtime Plugin Functionality:

  • New Dependencies:

    • Added dashmap and pollster to crates/rspack_plugin_runtime/Cargo.toml to support the new runtime plugin functionalities.
  • New Runtime Plugin Hooks and Data Structures:

    • Introduced new hooks and data structures in crates/rspack_plugin_runtime/src/drive.rs for CreateScriptData, LinkPreloadData, and LinkPrefetchData.
    • Updated crates/rspack_binding_values/src/runtime.rs to include new JsCreateScriptData, JsLinkPreloadData, and JsLinkPrefetchData structures.
  • Integration with Existing Plugins:

    • Modified crates/node_binding/src/plugins/interceptor.rs to register and handle new runtime plugin taps, including RuntimePluginCreateScript, RuntimePluginLinkPreload, and RuntimePluginLinkPrefetch. [1] [2]
    • Updated crates/node_binding/src/plugins/mod.rs to integrate the new runtime plugin hooks into the compilation process. [1] [2]
  • Runtime Module Enhancements:

    • Enhanced crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs to utilize the new runtime plugin hooks for link_prefetch and link_preload functionalities, ensuring that the appropriate scripts are created and linked during the chunk loading process. [1] [2]

These changes collectively improve the extensibility and functionality of the rspack runtime environment, allowing for more sophisticated script handling and loading strategies.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 4e16a0c
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/6790f99b3111430007c6b442
😎 Deploy Preview https://deploy-preview-9084--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.

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Jan 22, 2025
Copy link

codspeed-hq bot commented Jan 22, 2025

CodSpeed Performance Report

Merging #9084 will not alter performance

Comparing feat/runtime-plugin-hooks (4e16a0c) with main (06807ac)

Summary

✅ 3 untouched benchmarks

@LingyuCoder LingyuCoder enabled auto-merge (squash) January 22, 2025 14:03
@LingyuCoder LingyuCoder merged commit 7075fd2 into main Jan 23, 2025
30 checks passed
@LingyuCoder LingyuCoder deleted the feat/runtime-plugin-hooks branch January 23, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants