Skip to content

[heft-sass-plugin] Honor package exports for Sass imports - #6161

Open
Ian Clanton-Thuon (iclanton) wants to merge 1 commit into
microsoft:mainfrom
iclanton:heft-sass-package-exports
Open

Ian Clanton-Thuon (iclanton) wants to merge 1 commit into
microsoft:mainfrom
iclanton:heft-sass-package-exports

Conversation

@iclanton

Copy link
Copy Markdown
Member

Summary

Allow @rushstack/heft-sass-plugin to consume packages that expose stylesheets through package.json exports instead of requiring imports of their physical source paths. Support Sass-aware root exports, subpaths, wildcard patterns, and top-level sass/style entry points.

Details

  • Use resolve-pkg-maps to match export maps with the sass, style, and default conditions in manifest order. Apply Sass's extension, partial, and index-file lookup to exported subpaths; require complete stylesheet filenames in export targets.
  • Keep Heft's custom importer rather than delegate loading to NodePackageImporter, preserving preprocessing, dependency tracking, incremental recompilation, and source maps.
  • Share package resolution across pkg: imports, legacy ~ imports, and opt-in bare package imports. Relative/load-path precedence and the default behavior for bare specifiers remain unchanged.
  • Preserve Sass-style filesystem fallbacks when no export matches. Matching invalid or ambiguous exports now produce explicit errors instead of silently falling back.
  • Avoid leaving an unreadable exported stylesheet in the dependency cache when loading fails.
  • Add one small resolver dependency, update its lockfile/policy entries, document the behavior, and include a patch change file. Manifest reads use the existing per-compilation resolution cache.

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 99 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/SassProcessor.ts heft-plugins/heft-sass-plugin/src/test/SassProcessor.test.ts heft-plugins/heft-sass-plugin/package.json - 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.

Impacted documentation

Updated the heft-sass-plugin README with package entry-point examples and resolution rules. No website documentation or JSON schemas were changed.

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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant