Skip to content

feat: support extractComments in swcMinify#665

Merged
alexander-akait merged 9 commits into
webpack:mainfrom
kdy1:kdy1/swc-extract-comments
Apr 23, 2026
Merged

feat: support extractComments in swcMinify#665
alexander-akait merged 9 commits into
webpack:mainfrom
kdy1:kdy1/swc-extract-comments

Conversation

@kdy1

@kdy1 kdy1 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

This wires extractComments into TerserPlugin.swcMinify for SWC builds that support comment extraction.

What changed:

  • normalize serializable extractComments conditions for SWC (boolean, "some", "all", string patterns, RegExp without flags, and object conditions that resolve to those forms)
  • preserve legal comments by default when extractComments: false is used with swcMinify
  • surface result.extractedComments back to the plugin so existing filename/banner handling keeps working
  • error clearly for unsupported function conditions and flagged regular expressions
  • update the README warning to document the supported subset
  • add swcMinify coverage for default extraction, object { condition, filename, banner }, disabled extraction, and unsupported function conditions
  • remove the explicit @swc/core runtime version gate and rely on the installed SWC build to accept or reject the forwarded option

Verification:

  • npm run build
  • npx jest test/minify-option.test.js --runInBand
  • npm run lint:code -- src/utils.js test/minify-option.test.js
  • npx prettier --check README.md src/utils.js test/minify-option.test.js types/utils.d.ts

@linux-foundation-easycla

linux-foundation-easycla Bot commented Apr 16, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@kdy1

kdy1 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

Sorry I made a mistake with AI (codex).

My intention was to open this after publishing a new version of SWC.

I'll undraft this after publishing a new version.

@evenstensberg

Copy link
Copy Markdown
Member

@kdy1 could you sign the CLA?

@alexander-akait

Copy link
Copy Markdown
Member

@kdy1 feel free to ping when it was ready and we will make a release

@kdy1

kdy1 commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the delay. I'm trying to deploy (again) it with https://github.com/swc-project/swc/actions/runs/24608184505

The previous run failed in a strange way.

@kdy1 kdy1 marked this pull request as ready for review April 19, 2026 13:36
@kdy1

kdy1 commented Apr 19, 2026

Copy link
Copy Markdown
Contributor Author

@alexander-akait I think this PR is good to go. Thank you for waiting 😄

@codecov

codecov Bot commented Apr 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.76%. Comparing base (783427c) to head (7376988).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #665   +/-   ##
=======================================
  Coverage   96.76%   96.76%           
=======================================
  Files           3        3           
  Lines         340      340           
  Branches      126      126           
=======================================
  Hits          329      329           
  Misses         11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kdy1

kdy1 commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Can someone approve the CI run again?

@alexander-akait

Copy link
Copy Markdown
Member

Done

@alexander-akait

Copy link
Copy Markdown
Member

@kdy1 ignore CI failed, I will finish your PR (today/tomorrow), want to make some types improvement too

@alexander-akait alexander-akait merged commit 03143d3 into webpack:main Apr 23, 2026
29 checks passed
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.

3 participants