feat: load minimizers by module path in workers - #732
xiaoxiaojx wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 2575275 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #732 +/- ##
==========================================
+ Coverage 97.75% 97.78% +0.02%
==========================================
Files 4 5 +1
Lines 1557 1623 +66
Branches 588 617 +29
==========================================
+ Hits 1522 1587 +65
- Misses 35 36 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
6ad15aa to
e50aeee
Compare
The default minimizer is named by module path, the minimizer loop reads the slots this branch introduced, and both hash guards ask the slots how many there are.
Plus the case the test plan left open: one function among several paths leaves the whole task on the source path.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. WalkthroughThe plugin now accepts minimizer implementations as functions, module path strings, or Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
src/implementation.jsESLint failed to execute (timeout). src/index.jsESLint skipped: the matched ESLint configuration already failed (timeout). test/parallel-option.test.jsESLint skipped: the matched ESLint configuration already failed (timeout).
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Pass the loaded minimizer function to declaredStage(). · index.js:1920
src/index.js:1920
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPass the loaded minimizer function to
declaredStage(). A module path or{ path, export }value does not expose the loaded function'sgetStage, so that minimizer usesdefaultStage()instead of its declared stage. Use the corresponding loaded slot function while preserving the slot index for dispatch.Proposed fix
minimizersByStage(compiler) { - const { implementation } = this.options.minimizer; - const each = Array.isArray(implementation) - ? implementation - : [implementation]; + const slots = this.getMinimizerSlots(); const fallback = this.defaultStage(compiler); const byStage = new Map(); - for (let i = 0; i < each.length; i++) { - const asked = declaredStage(compiler, each[i]); + for (let i = 0; i < slots.length; i++) { + const asked = declaredStage(compiler, slots[i].fn);
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 379b994c-fa58-470a-871e-7617fe8e2621
⛔ Files ignored due to path filters (2)
test/__snapshots__/parallel-option.test.js.snapis excluded by!**/*.snaptest/__snapshots__/validate-options.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (14)
.changeset/worker-implementation-path.mdREADME.mdsrc/implementation.jssrc/index.jssrc/minify.jssrc/options.jsontest/extractComments-option.test.jstest/fixtures/minify-default-export.jstest/fixtures/minify-default-property.jstest/implementation.test.jstest/parallel-option.test.jstypes/implementation.d.tstypes/index.d.tstypes/minify.d.ts
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.
A required minimizer is handed the payload as it is, so an extractComments callback or a function in a minimizer's own options died as could not be cloned; generators stay callable-only, which is all the schema takes.
Summary
minimizer.implementationas a module path string or{ path, export }(sass-loader style). Default terser uses{ path, export: "terserMinify" }.embedded) is a path, workersrequireviaminifyinstead ofserialize-javascript+new Function(transform). Inline minify functions keep the legacy path.implementation.jsso the worker entry only exportsminify/transform; unify loading throughgetMinimizerSlots/embeddedFromSlots.Test plan
yarn test(full suite)worker.minify(nottransform)minify: () => …/ mixed path+function configs fall back totransformminimizer-handoff-unitbench against rebuiltdistMade with Cursor
Summary by CodeRabbit
New Features
{ path, export }objects.Documentation