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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support minifyoptions extract comments #2882

Conversation

faga295
Copy link
Contributor

@faga295 faga295 commented Apr 23, 2023

Related issue (if exists)

closed #2772

Summary

馃 Generated by Copilot at fe03709

This pull request adds a new feature to the rspack bundler that allows extracting comments from minified JavaScript code and emitting them as separate assets. It modifies the rspack_plugin_javascript crate, the rspack_binding_options crate, the rspack_core crate, and the rspack package to support this feature. It also updates the examples/basic folder to demonstrate the usage of this feature.

Walkthrough

馃 Generated by Copilot at fe03709

  • Add a new feature to extract comments from the minified JavaScript code based on a regular expression or a keyword (link, link, link, link, link, link, link, link, link, link)
  • Modify the stringify function to optionally omit the comments from the output code based on a retain_comments flag (link, link)
  • Pass the retain_comments flag to the stringify function from the generate method of the JavaScriptParserAndGenerator struct (link)
  • Add a new struct ExtractedCommentsInfo to store the information about the extracted comments for a file (link)
  • Modify the configuration file rspack.config.js in the examples/basic folder to enable the comment extraction feature and set the regular expression for the extractComments field (link)
  • Modify the source file index.js in the examples/basic/src folder to contain various types of comments for testing purposes (link)
  • Add some debugging statements to the minify function and the from method of the RawMinification struct for testing purposes (link, link, link)
  • Modify some imports in the minify.rs and plugin.rs files to use the new types and modules (link, link, link)
  • Remove some empty lines from the minify.rs and visitors.rs files for formatting purposes (link, link, link)

@changeset-bot
Copy link

changeset-bot bot commented Apr 23, 2023

馃 Changeset detected

Latest commit: 60e2295

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/postcss-loader Patch
webpack-test Patch
@rspack/cli 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

@faga295 faga295 marked this pull request as ready for review April 26, 2023 14:06
@IWANABETHATGUY
Copy link
Contributor

!bench

@github-actions
Copy link
Contributor

Benchmark Results

group                                                 baseline                               pr
-----                                                 --------                               --
criterion_benchmark/ten_copy_of_threejs               1.00       2.7卤0.07s        ? ?/sec    1.00       2.7卤0.08s        ? ?/sec
high_cost_benchmark/ten_copy_of_threejs_production    1.01       9.5卤0.11s        ? ?/sec    1.00       9.3卤0.12s        ? ?/sec

@IWANABETHATGUY
Copy link
Contributor

Overall, looks good to me, would you mind rebasing the main branch, so I could approve and merge.

Copy link
Contributor

@IWANABETHATGUY IWANABETHATGUY left a comment

Choose a reason for hiding this comment

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

Thanks!

@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Apr 27, 2023
Merged via the queue into web-infra-dev:main with commit 2bb2bcd Apr 27, 2023
10 checks passed
@github-actions github-actions bot mentioned this pull request May 9, 2023
siyou pushed a commit to siyou/rspack that referenced this pull request May 14, 2023
* chore: init

* feat: support regex match

* chore: clear comments in minimized file

* chore: update

* chore: no license no LICENSE.TXT

* test: add test cases

* test: add comments for expected

* chore: update

* chore: remove comments

* chore: add expected file

* chore: add comments

* chore: changeset

* chore: comment

* chore: update snapshots

* chore: update

* chore: resolve config

* chore: update filename

* chore: update name

* chore: update name
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.

support extractComments in minifyOptions
3 participants