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: add moduleAssets for stats #2864

Merged
merged 4 commits into from
Apr 23, 2023
Merged

feat: add moduleAssets for stats #2864

merged 4 commits into from
Apr 23, 2023

Conversation

ahabhgk
Copy link
Contributor

@ahabhgk ahabhgk commented Apr 21, 2023

Related issue (if exists)

part of #2610

Summary

🤖 Generated by Copilot at 72d58f6

This pull request refactors the code related to the assets field of the Compilation struct and its wrappers, and adds support for tracking and including assets information in the statistics and the output of the compilation. It also introduces minor improvements to some plugins and structs that use or produce assets. The main files affected are crates/rspack_core/src/compiler/compilation.rs, crates/rspack_core/src/stats.rs, and crates/node_binding/src/js_values/stats.rs.

Walkthrough

🤖 Generated by Copilot at 72d58f6

  • Refactor the Compilation struct to use getter and setter methods for the assets field, instead of direct field access, to improve encapsulation and avoid direct mutation of the assets (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)
  • Add a new field assets to the JsStats struct in crates/node_binding/src/js_values/stats.rs, which stores the names of the assets associated with each module or chunk, if the moduleAssets option is enabled (link,link,link,link)
  • Add a new field asset_filenames to the Module struct in crates/rspack_core/src/module.rs, which stores the names of the assets associated with the module (link)
  • Add a new field asset_filenames to the LoaderResult and LoaderContext structs in crates/rspack_loader_runner/src/runner.rs, which stores the names of the assets emitted by the loader (link,link,link,link)
  • Add a new field asset_filenames to the JsLoaderResult struct in crates/rspack_binding_options/src/options/raw_module/js_loader.rs, which stores the names of the assets emitted by the loader (link,link)
  • Initialize the asset_filenames field of the Module struct from the LoaderResult struct in crates/rspack_core/src/normal_module.rs (link)
  • Add a new parameter module_assets to the get_modules and get_chunks methods of the Stats struct in crates/rspack_core/src/stats.rs, which indicates whether to include the assets associated with each module or chunk in the output (link,link,link,link)
  • Add a new field assets to the StatsModule and StatsChunk structs in crates/rspack_core/src/stats.rs, which stores the names of the assets associated with the module or chunk, if the moduleAssets option is enabled (link,link)
  • Initialize the assets field of the StatsModule struct from the Module struct in crates/rspack_core/src/stats.rs (link,link)
  • Add the #[derive(Debug, Clone)] attribute to the CssMinifyOptions struct in crates/rspack_plugin_css/src/lib.rs, which enables the implementation of the Debug and Clone traits for the struct (link)
  • Replace the inline creation of the SwcCssSourceMapGenConfig and JsMinifyOptions structs with variables that are initialized once and cloned for each file, in crates/rspack_plugin_css/src/plugin.rs and crates/rspack_plugin_javascript/src/plugin.rs, to avoid repeating the same code and improve readability and performance (link,link)
  • Add a new variable context that stores the value of the compilation.options.context field, in crates/rspack_plugin_devtool/src/lib.rs, to avoid repeating the field access multiple times and improve readability and performance (link)

@changeset-bot
Copy link

changeset-bot bot commented Apr 21, 2023

🦋 Changeset detected

Latest commit: 91f4d67

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@rspack/binding Patch
@rspack/core Patch
@rspack/cli Patch
@rspack/postcss-loader Patch
webpack-test Patch
@rspack/dev-middleware Patch
@rspack/dev-server Patch
@rspack/plugin-html Patch
benchmarkcase-rspack-react-refresh Patch
@rspack/dev-client Patch
@rspack/plugin-minify Patch
@rspack/plugin-node-polyfill Patch
@rspack/binding-darwin-arm64 Patch
@rspack/binding-darwin-x64 Patch
@rspack/binding-linux-x64-gnu Patch
@rspack/binding-win32-x64-msvc Patch
@rspack/fs Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added release: feature team The issue/pr is created by the member of Rspack. labels Apr 21, 2023
hyf0
hyf0 previously approved these changes Apr 21, 2023
@ahabhgk ahabhgk requested a review from hyf0 April 23, 2023 04:35
@ahabhgk ahabhgk added this pull request to the merge queue Apr 23, 2023
Merged via the queue into main with commit bc65893 Apr 23, 2023
@ahabhgk ahabhgk deleted the stats-modules-assets branch April 23, 2023 06:34
@github-actions github-actions bot mentioned this pull request Apr 25, 2023
siyou pushed a commit to siyou/rspack that referenced this pull request May 14, 2023
* stats-module-assets

* add changset

* fmt

* fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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