Skip to content

feat: support require.ensure#7972

Merged
LingyuCoder merged 18 commits intoweb-infra-dev:mainfrom
CPunisher:feat/require-ensure
Oct 21, 2024
Merged

feat: support require.ensure#7972
LingyuCoder merged 18 commits intoweb-infra-dev:mainfrom
CPunisher:feat/require-ensure

Conversation

@CPunisher
Copy link
Copy Markdown
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
@netlify
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
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