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: support require.ensure #7972

Merged
merged 18 commits into from
Oct 21, 2024

Conversation

CPunisher
Copy link
Contributor

@CPunisher CPunisher commented Sep 24, 2024

Summary

closes #4304

Because rspack has not supported some API yet, this pr doesn't fully align require.ensure to webpack. But I think it's enough to use.

  1. Webpack calls parser.in_scope when adding RequireEnsureItemDependency to depBlock. This API is marked as deprecated.
  2. Webpack save dependencies and dependency block in nested block by setting parser.state.current = depBlock, which bundles the modules required in the success body to the created AsyncDependencyBlock. But rspack doesn't not support nested blocks yet.
    Related test case: https://github.com/web-infra-dev/rspack/tree/3beef37ec09a565da86b8211e6712655f6aefa32/tests/webpack-test/configCases/parsing/issue-14720
    Reated webpack issue: Inside require.ensure, using require with chained property causes dependencies to be added to wrong chunk webpack/webpack#14720

Checklist

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

@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Sep 24, 2024
Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for rspack ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2bb207e
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/671519ae452f860008cd3c5c
😎 Deploy Preview https://deploy-preview-7972--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.

@CPunisher CPunisher marked this pull request as ready for review September 26, 2024 12:46
@CPunisher CPunisher force-pushed the feat/require-ensure branch from 55c6e8b to b7664de Compare October 12, 2024 07:21
@LingyuCoder
Copy link
Contributor

Perhaps some cases can be added to the runtime diff test to make sure that the generated runtime code is full aligned with webpack.

@CPunisher CPunisher force-pushed the feat/require-ensure branch from b7664de to 2bb207e Compare October 20, 2024 14:54
Copy link
Contributor

@LingyuCoder LingyuCoder left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@LingyuCoder LingyuCoder merged commit 6a66a71 into web-infra-dev:main Oct 21, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: feature release: feature related release(mr only)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support require.ensure
2 participants