You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Unnecessary Buffer polyfill when source maps are disabled #454
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
After upgrading from css-loader 0.26.4 to 0.27.3 webpack is including a polyfill for Buffer in the bundle when source maps are not enabled. This is resulting in an increased bundle size, even though the polyfill is never actually used.
If the current behavior is a bug, please provide the steps to reproduce.
Install css-loader 0.23.7, run a webpack build, and check the resulting bundle.
What is the expected behavior?
If source maps are not enabled, then there is no need to output the toComment function in lib/css-base.js, which uses Buffer. The loader should only output this function if source maps are enabled.
Please mention other relevant information such as your webpack version, Node.js version and Operating System.
Windows 8.1
Node 6.9.5
Webpack 2.2.1
My current workaround is just adding
node: {
Buffer: false
}
to the webpack config, but I think it would be better if the loader could handle this.
Reacted by Denis Koltsov, Jinhyeok Lee, mrsufgi, Rob Walch, Bri Stanback, elfey and Ben Wyss
Nope that doesn't seem to work. I tried removing the function too and just inlining it the if (useSourceMap) statement, but the Buffer polyfill is still being included.
Activity
michael-ciniawsky commentedon Mar 14, 2017
@alexwalter88 https://github.com/webpack-contrib/css-loader/blob/master/lib/loader.js#L113 Normally it should exaclty do that, but guessing the
toCommentfunction needs to be moved into theif (useSourceMap)statement to avoid including the Buffer polyfillmichael-ciniawsky commentedon Mar 14, 2017
Mind testing quickly testing that out ? 😛
ArgonAlex commentedon Mar 14, 2017
Nope that doesn't seem to work. I tried removing the function too and just inlining it the
if (useSourceMap)statement, but the Buffer polyfill is still being included.michael-ciniawsky commentedon Mar 14, 2017
Alright I need to ask Tobias what to do about it at best, I come back when I know more :). Meanwhile please continue using your workaround 😛
bebraw commentedon Mar 14, 2017
I guess the question is, how to rewrite
without relying on
Buffer. That would be one way.bebraw commentedon Mar 14, 2017
See MDN. Either
btoaor solution#1from that page would likely solve this.michael-ciniawsky commentedon Apr 20, 2017
Closed by #501