Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
246 stars 42 forks source link

feat: add basic support resolving conditional package exports #197

Closed kherock closed 2 years ago

kherock commented 3 years ago

This adds basic support for importing styles from a bare package export when the package.json is using an exports map. The implementation is loosely inspired by Jest's upcoming support for them:

https://github.com/facebook/jest/blob/bc3c921251193e88eca0d94ca6bd5ab92a137cbf/packages/jest-resolve/src/defaultResolver.ts#L84-L126

I've copied the conditions of webpack's sass-loader with regards to imports from a sass context:

https://github.com/webpack-contrib/sass-loader/blob/0ab22f0a015ac807594482595171b55e8852852c/src/utils.js#L481-L491

codecov[bot] commented 2 years ago

Codecov Report

Merging #197 (407733b) into main (b402687) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #197   +/-   ##
=======================================
  Coverage   99.62%   99.63%           
=======================================
  Files          36       36           
  Lines        1069     1083   +14     
  Branches      298      318   +20     
=======================================
+ Hits         1065     1079   +14     
- Misses          1        4    +3     
+ Partials        3        0    -3     
Impacted Files Coverage Δ
src/loaders/sass/importer.ts 100.00% <100.00%> (ø)
src/loaders/sass/index.ts 96.15% <0.00%> (-0.52%) :arrow_down:
src/index.ts 99.45% <0.00%> (-0.01%) :arrow_down:
src/utils/concat.ts 100.00% <0.00%> (ø)
src/loaders/index.ts 97.36% <0.00%> (ø)
src/utils/resolve.ts 100.00% <0.00%> (ø)
src/loaders/stylus.ts 100.00% <0.00%> (ø)
__tests__/helpers/index.ts 100.00% <0.00%> (ø)
src/loaders/postcss/index.ts 100.00% <0.00%> (ø)
src/loaders/postcss/url/index.ts 98.86% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b402687...407733b. Read the comment docs.