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 experiments.outputModule #2803

Merged
merged 10 commits into from
Apr 19, 2023
Merged

feat: support experiments.outputModule #2803

merged 10 commits into from
Apr 19, 2023

Conversation

underfin
Copy link
Contributor

@underfin underfin commented Apr 18, 2023

Related issue (if exists)

close #2612

Summary

  • migrate webpack ConfigCase.template.js to configCase test

🤖 Generated by Copilot at 5a87e69

This pull request adds support for generating ES modules as output for the rspack bundler. It introduces new plugins, runtime modules, and output types to handle the module format and the dynamic import feature. It also enables tree shaking for the "module" output type and passes the entry module identifier to the plugins for more flexibility. It refactors some existing code and comments out some error checking for the AMD library name.

Walkthrough

🤖 Generated by Copilot at 5a87e69

  • Add new output types and plugins for generating ES modules for chunks (link, link, link, link, link, link, link)
  • Enable tree shaking analysis for the "module" output type and make the results available for all configurations (link, link)
  • Pass the last entry module of the chunk to the render_startup hook of the plugins and use it to generate the startup code for the chunk (link, link, link, link, link, link, link)
  • Add new runtime modules for exporting the __webpack_require__ function and handling the chunk loading logic for the "module" and the "import" output types (link, link, link, link, link, link, link, link)
  • Enable the ModuleLibraryPlugin for the "module" output type and use the tree shaking analysis results to generate the export names for the entry module (link, link, link)
  • Enable the ModuleChunkFormatPlugin for the "module" output type and use the RuntimeGlobals::STARTUP_ENTRYPOINT global variable to store the entry point function for the chunk (link, link, link, link)
  • Enable the ModuleChunkLoadingPlugin for the "import" output type and use the get_runtime_chunk_path function to get the relative path to the runtime chunk (link, link, link, link, link)
  • Simplify the code for getting the relative path to the runtime chunk in the CommonJsChunkFormatPlugin by using the get_runtime_chunk_path function (link, link)
  • Move the property_access function from the assign_library_plugin.rs module to the utils.rs module and import it from there (link, link)
  • Comment out the normalize_name function in the utils.rs module to temporarily disable the error checking for the AMD library name (link)

@changeset-bot
Copy link

changeset-bot bot commented Apr 18, 2023

⚠️ No Changeset found

Latest commit: 6fb2f3e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@hyf0 hyf0 changed the title feat: output module feat: support experiments.outputModule Apr 18, 2023
@underfin underfin enabled auto-merge April 18, 2023 08:59
@IWANABETHATGUY
Copy link
Contributor

Overall, LGTM. But it seems that you only used export_info, but hold the whole tree_shaking_result until the compilation is finished, this gonna consume a lot of unnecessary memory. I think this is alright to merge this pr and left the optimization in the future, but would you mind opening a new issue to track this?

@IWANABETHATGUY
Copy link
Contributor

One more question, is this feature used a lot? outputModule: true

@underfin
Copy link
Contributor Author

One more question, is this feature used a lot? outputModule: true

Not sure..

@underfin underfin disabled auto-merge April 18, 2023 09:39
IWANABETHATGUY
IWANABETHATGUY previously approved these changes Apr 19, 2023
@underfin underfin added this pull request to the merge queue Apr 19, 2023
Merged via the queue into main with commit 7874687 Apr 19, 2023
@underfin underfin deleted the output-module branch April 19, 2023 09:37
IWANABETHATGUY pushed a commit that referenced this pull request Apr 19, 2023
* feat: output module

* fix: format

* fix: test

* fix: test

* fix: test

* fix: avoid add tree_shaking_result

* fix: test

* fix: test

* fix: test

* fix: test
siyou pushed a commit to siyou/rspack that referenced this pull request May 14, 2023
* feat: output module

* fix: format

* fix: test

* fix: test

* fix: test

* fix: avoid add tree_shaking_result

* fix: test

* fix: test

* fix: test

* fix: test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: module output
3 participants