rspack icon indicating copy to clipboard operation
rspack copied to clipboard

feat: support `require.ensure`

Open CPunisher opened this issue 5 months ago • 1 comments

Summary

closes https://github.com/web-infra-dev/rspack/issues/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: https://github.com/webpack/webpack/issues/14720
  • [ ] The last test to update is: https://github.com/web-infra-dev/rspack/blame/5dd01e2abf32837b153d62ed64d1c0d1caaa299a/packages/rspack-test-tools/tests/statsOutputCases/limit-chunk-count-plugin/rspack.config.js#L1 by @SyMind

Checklist

  • [x] Tests updated (or not required).
  • [x] Documentation updated (or not required).

CPunisher avatar Sep 24 '24 14:09 CPunisher