build(deps): bump 5 deps to latest major + fix ESM module loading - #152
Merged
Conversation
Major bumps (Batch A): - mime-types 2->3 (Node >=18, mime-score resolution; lookup() API unchanged) - cosmiconfig 8->9 (add searchStrategy: 'global' to preserve upward dir traversal) - p-queue 8->9 (Node >=20; API surface unchanged) - sugarss 4->5 (Node >=18; parser interface unchanged) - postcss-custom-properties 14->15 (Node >=20.19; ESM-only, options unchanged) - @types/mime-types 2->3 (matching types; lookup() signature identical) - engines.node: >=20.19.0 (was already required by sass 1.102 from Phase 1) Bug fixes required by postcss-custom-properties v15 (ESM-only with exports): - fix(resolve): handle array returns from resolveExports in packageFilterBuilder (resolveExports returns string[] for packages with nested exports maps; the existing code only checked typeof === 'string', missing array results) - fix(load-module): make async with ESM fallback via dynamic import() (require() of .mjs fails in jest VM context; fall back to await import()) Uses packageFilterBuilder() instead of no-op packageFilter to resolve packages that only have an exports field (no main/module) - fix(options): make ensurePCSSOption/ensurePCSSPlugins async - fix(postcss/index): resolve parser/syntax/stringifier/plugins lazily in async process() instead of eagerly in sync plugin factory - fix(config): await async ensurePCSSOption/ensurePCSSPlugins calls - fix(types): postcss sub-options accept string (resolved lazily) - fix(tests): update load-module/ensurePCSSOption tests to async
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
+ Coverage 98.75% 98.97% +0.22%
==========================================
Files 36 36
Lines 962 974 +12
Branches 313 317 +4
==========================================
+ Hits 950 964 +14
+ Misses 12 10 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add unit test for ensurePCSSPlugins([[autoprefixer]]) which exercises the else branch (line 99) where a plugin is specified as an array with only the name and no options object. Resolves codecov patch coverage.
loadModule now resolves and loads ESM-only packages that only have an exports field (no main/module). Falls back to dynamic import() when require() fails for .mjs files (e.g. in jest VM context). packageFilterBuilder handles array returns from resolveExports, which is the return type for all modern package exports shapes (flat and nested). parser/syntax/stringifier/plugins options are now resolved lazily in the async postcss process() hook instead of eagerly in the sync plugin factory, enabling async module loading.
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 Batch A — 5 isolated major dep bumps, plus bug fixes required to support ESM-only packages with
exportsfields in the module loader.Major dep bumps
mime-typeslookup()API unchangedcosmiconfigsearchStrategydefaults tononesearchStrategy: 'global'p-queueconcurrency,.add()unchangedsugarsspostcss-custom-propertiesAlso bumped
@types/mime-types2→3 (matching types) andengines.nodeto>=20.19.0(was already required bysass1.102 from Phase 1 PR #151).Bug fixes (required by postcss-custom-properties v15)
postcss-custom-propertiesv15 is ESM-only with a nestedexportsmap ({".": {types:..., default:...}}). This exposed two pre-existing bugs in the module loader:1.
fix(resolve): handle array returns fromresolveExportsresolveExports()returnsstring[]for packages with nested exports maps, butpackageFilterBuilderonly checkedtypeof === 'string', missing array results. Added array handling.2.
fix(load-module): async with ESM fallbackrequire()of.mjsfiles fails in jest VM context ("Must use import to load ES Module"). Added fallback toawait import()whenrequire()fails.packageFilter: pkg => pkgwithpackageFilterBuilder()so packages with only anexportsfield (nomain/module) can be resolved.Ripple changes (making sync code async)
ensurePCSSOption/ensurePCSSPlugins→ asyncparser/syntax/stringifier/pluginslazily in asyncprocess()instead of eagerly in sync plugin factoryconfig.ts:awaitasync callstypes.ts: postcss sub-options acceptstring(resolved lazily)await loadModule(...),rejects.toThrowErrorMatchingSnapshot())cosmiconfigbehavior preservationAdded
searchStrategy: 'global'to preserve v8's default upward directory traversal behavior (v9 defaults tonone). Test fixtures have co-located configs, but real users may rely on parent-dir config discovery.Verification
npm run lint(prettier + eslint)npm run build(rollup + type emit)npm test— 4 suites, 113 tests, 314 snapshots pass (no snapshot changes)What's next