Repository navigation
[heft-sass-plugin] Honor package exports for Sass imports - #6161
Merged
Ian Clanton-Thuon (iclanton) merged 4 commits intoOct 27, 2026
Merged
Ian Clanton-Thuon (iclanton) merged 4 commits into
Ian Clanton-Thuon (iclanton) merged 4 commits into
Conversation
Sean Larkin (TheLarkInn)
approved these changes
Oct 21, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Manifest changes can leave cached CSS stale, and dotted-subpath and wildcard-directory cases can prevent valid index exports from resolving.
3 open issues
1 file not reviewed
common/config/subspaces/default/pnpm-lock.yaml: Generated file
What changed in this PR
Adds package-export resolution to Heft’s Sass importer while preserving its custom loading and preprocessing.
Changes:
- Supports Sass-aware exports, subpaths, wildcards, and package entry points.
- Adds resolver and processor regression tests with package fixtures.
- Updates documentation, dependency metadata, and patch-release notes.
| File | Description |
|---|---|
| heft-plugins/heft-sass-plugin/src/test/SassProcessor.test.ts | Tests importer integration and output behavior. |
| heft-plugins/heft-sass-plugin/src/test/SassPackageResolver.test.ts | Tests export resolution and Sass compatibility. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/src/exports.module.scss | Adds package-import fixture. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/styles/plain.css | Adds CSS fixture. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/styles/other.scss | Adds alternate target. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/styles/indented.sass | Adds indented Sass fixture. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/styles/_tokens.scss | Exercises relative dependencies. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/styles/_spaced tokens.scss | Exercises encoded paths. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/styles/_palette.scss | Supplies dependency values. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/package.json | Defines fixture exports. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/node_modules/@test/exported-styles/_index.scss | Exercises index fallback. |
| heft-plugins/heft-sass-plugin/src/test/fixtures/package-exports/.gitignore | Allows checked-in package fixtures. |
| heft-plugins/heft-sass-plugin/src/test/__snapshots__/SassProcessor.test.ts.snap | Records integration outputs. |
| heft-plugins/heft-sass-plugin/src/SassProcessor.ts | Integrates package resolution and content reuse. |
| heft-plugins/heft-sass-plugin/src/SassPackageResolver.ts | Implements Sass export matching. |
| heft-plugins/heft-sass-plugin/README.md | Documents package-resolution rules. |
| heft-plugins/heft-sass-plugin/package.json | Adds resolver dependency. |
| common/config/subspaces/default/repo-state.json | Updates lockfile hash. |
| common/config/subspaces/default/pnpm-lock.yaml | Locks resolver dependency. |
| common/config/rush/nonbrowser-approved-packages.json | Approves resolver package. |
| common/changes/@rushstack/heft-sass-plugin/sass-package-exports_2026-10-20-18-44.json | Adds patch-release note. |
Review effort: Balanced
Bharat Middha (bmiddha)
approved these changes
Oct 21, 2026
Ian Clanton-Thuon (iclanton)
enabled auto-merge (squash)
October 21, 2026 19:55
David Michon (dmichon-msft)
requested changes
Oct 21, 2026
David Michon (dmichon-msft)
left a comment
Collaborator
There was a problem hiding this comment.
If we're supporting package.json exports we should match the spec for package.json exports, which have very specific rules about the keys and values.
David Michon (dmichon-msft)
approved these changes
Oct 23, 2026
Resolve Sass-aware package entry points while preserving Heft loading, dependency tracking, source maps, and legacy imports. Add regression coverage and document the supported resolution behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract a testable package resolver, retain wildcard file contents, and handle wildcard fallback arrays. Check in package fixtures, use asynchronous test I/O, and address package typing and policy feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep Sass manifest types with the resolver and clarify preloaded content caching. Compare importer results using platform-aware path semantics so Windows drive-letter casing does not cause false test failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Invalidate stylesheet consumers when package entry points change, including persisted caches and watch mode. Treat wildcard directory candidates as non-matches so index exports remain reachable, and add regression coverage against Sass's own importer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ian Clanton-Thuon (iclanton)
force-pushed
the
heft-sass-package-exports
branch
from
October 26, 2026 22:57
2ac0635 to
ea6084d
Compare
Ian Clanton-Thuon (iclanton)
merged commit Oct 27, 2026
9d7592f
into
microsoft:main
17 of 19 checks passed
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
Allow
@rushstack/heft-sass-pluginto consume packages that expose stylesheets throughpackage.jsonexports instead of requiring imports of their physical source paths. Support Sass-aware root exports, subpaths, wildcard patterns, and top-levelsass/styleentry points.Details
resolve-pkg-mapsto match export maps with thesass,style, anddefaultconditions in manifest order. Apply Sass's extension, partial, and index-file lookup to exported subpaths; require complete stylesheet filenames in export targets.SassPackageResolverutility. Compare representative results with Sass's built-inNodePackageImporter.NodePackageImporter, preserving preprocessing, dependency tracking, incremental recompilation, and source maps.pkg:imports, legacy~imports, and opt-in bare package imports. Relative/load-path precedence and the default behavior for bare specifiers remain unchanged.exports,sass, orstylenow invalidate consumers, including after restoring the cache. Version the incremental cache so earlier caches without manifest dependencies are not reused.node_moduleslayout through a local.gitignoreexception, and use asynchronous fixture setup and cleanup.How it was tested
rush build --only @rushstack/heft-sass-plugin- passed.rush retest --only @rushstack/heft-sass-plugin- passed on the final commit, including build/lint and all 148 tests.rush install --to @rushstack/heft-sass-plugin- passed lockfile and repository-state validation.common/autoinstallers/rush-prettier/node_modules/.bin/prettier --check heft-plugins/heft-sass-plugin/src/SassPackageResolver.ts heft-plugins/heft-sass-plugin/src/SassProcessor.ts heft-plugins/heft-sass-plugin/src/SassPlugin.ts heft-plugins/heft-sass-plugin/src/test/SassPackageResolver.test.ts heft-plugins/heft-sass-plugin/src/test/SassProcessor.test.ts heft-plugins/heft-sass-plugin/src/test/SassPlugin.test.ts- passed.git diff --cached --check- passed; the pre-commit formatting hook also passed.Regression coverage includes scoped packages, root/subpath exports, condition ordering, arrays, wildcard/exact mappings, Sass partials and index files, encoded paths, CSS and indented Sass, legacy/bare imports, entry-point fallbacks, invalid/missing/ambiguous targets, source maps, and dependency-triggered recompilation. Additional regressions cover manifest-only retargeting with in-memory and persisted caches, manifest watch registration and change events, nested package imports, wildcard directory indexes, and dotted-subpath behavior compared with Sass's own importer.
Impacted documentation
Updated the heft-sass-plugin README with package entry-point examples and resolution rules. No website documentation or JSON schemas were changed.