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
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 typefunction
to becomeundefined
. It seems that we can fix this behavior quite easily without breaking anything by adding a check fortypeof === 'function'
and calling(locals)[key].toString()
instead ofJSON.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