Anidetrix / rollup-plugin-styles

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

fix: Fix modules export with inject fn #128

Closed tjenkinson closed 4 years ago

tjenkinson commented 4 years ago

We noticed if you use use the 'inject' mode with a function the module exports object is not included.

This fixes that.

Also it changes const to var so that the output is es5. I think this makes sense given even though rollup itself supports es6, it keeps anything it generates itself to es5.

E.g.

export var test = 1;

becomes

var myBundle = (function (exports) { // <--- var
    'use strict';

    var test = 1;

    exports.test = test;

    return exports;

}({}));

with the iife format.

The typescript compiler was also also complaining because it looks like rollup added support for assetFileNames to be a function, which is currently not handled. I updated the code to throw an exception in this case for now.

codecov[bot] commented 4 years ago

Codecov Report

Merging #128 into master will decrease coverage by 0.09%. The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
- Coverage   99.60%   99.51%   -0.10%     
==========================================
  Files          36       36              
  Lines        1020     1022       +2     
  Branches      266      267       +1     
==========================================
+ Hits         1016     1017       +1     
- Misses          1        2       +1     
  Partials        3        3              
Impacted Files Coverage Δ
src/index.ts 98.78% <50.00%> (-0.61%) :arrow_down:
src/loaders/postcss/index.ts 100.00% <100.00%> (ø)

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 fcfa57f...8d8e177. Read the comment docs.

Anidetrix commented 4 years ago

Thank you for your contribution @tjenkinson! Also thank you for noticing assetFileNames change, was busy lately and missed that, I'll fix that as soon as I can.

tjenkinson commented 4 years ago

Thanks for the super quick review! There was another place where const is used. I'll open a new PR