webpack-contrib / mini-css-extract-plugin

Lightweight CSS extraction plugin
MIT License
4.65k stars 389 forks source link

Handling exported functions #984

Closed yungvldai closed 1 year ago

yungvldai commented 1 year ago

Hi! First of all thank you for your work!

Modification Proposal

I came across an interesting case in which a custom (modified) css-loader exports functions (as named exports). The current implementation uses JSON.stringify, which causes export values of type function ​​to become undefined. It seems that we can fix this behavior quite easily without breaking anything by adding a check for typeof === 'function' and calling (locals)[key].toString() instead of JSON.stringify((locals)[key]).

What do you think?

Expected Behavior / Situation

Function code is inserted instead of undefined

Actual Behavior / Situation

Function code turns into undefined

Please paste the results of npx webpack-cli info here, and mention other relevant information

alexander-akait commented 1 year ago

PR welcome :+1:

yungvldai commented 1 year ago

Thank you for answer! PR #985

alexander-akait commented 1 year ago

Fixed