Skip to content

Conversation

@chenjiahan
Copy link
Member

Summary

Move crypto imports from top-level to lazy require calls within functions to improve start up performance by deferring module loading until needed.

image

Checklist

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

@chenjiahan chenjiahan requested a review from hardfist as a code owner October 20, 2025 13:08
Copilot AI review requested due to automatic review settings October 20, 2025 13:08
@netlify
Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit cc1bfcb
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68f63cd346ae7a00083db10c

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves startup performance by moving Node.js crypto module imports from top-level imports to lazy require calls within functions, deferring module loading until the crypto functionality is actually needed.

Key changes:

  • Removed top-level crypto imports in favor of function-scoped require calls
  • Applied this optimization to both hash creation utilities and subresource integrity functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/rspack/src/util/createHash.ts Replaced top-level crypto import with lazy requires in hash creation functions
packages/rspack/src/builtin-plugin/SubresourceIntegrityPlugin.ts Moved crypto import from module level to function scope in computeIntegrity

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: performance release: performance related release(mr only) labels Oct 20, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

📦 Binary Size-limit

Comparing cc1bfcb to chore: enable Rslint rule: no-empty-interface (#11915) by Dima Shugaev

🙈 Size remains the same at 47.73MB

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 20, 2025

CodSpeed Performance Report

Merging #11930 will not alter performance

Comparing node_crypto_1020 (cc1bfcb) with main (e3199f4)

Summary

✅ 17 untouched

@chenjiahan chenjiahan merged commit 28f0a71 into main Oct 21, 2025
72 of 74 checks passed
@chenjiahan chenjiahan deleted the node_crypto_1020 branch October 21, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: performance release: performance related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants