postcss / postcss-selector-parser

A CSS selector parser, integrates with postcss but does not require it.
MIT License
205 stars 48 forks source link

fix: replace node built-in "util" module with "util-deprecate" #210

Closed nolanlawson closed 4 years ago

nolanlawson commented 4 years ago

Using the Node built-in util module can causes errors or warnings when using bundlers such as Rollup, since the module only exists in Node, not the browser. (This may require the use of something like rollup-plugin-node-builtins.)

We only need util for the util.deprecate() function, so we can rely on util-deprecate instead, which simply wraps util.deprecate() in Node as well as providing a browser-based equivalent.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 95.38% when pulling 75e38f7a7db8d58fb033ab7d24414b55d81e5b4f on nolanlawson:util-deprecate into 56156f70701eb6047baeba6f454fd497488d4bee on postcss:master.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 95.38% when pulling 75e38f7a7db8d58fb033ab7d24414b55d81e5b4f on nolanlawson:util-deprecate into 56156f70701eb6047baeba6f454fd497488d4bee on postcss:master.

nolanlawson commented 4 years ago

Per my measurements, this PR would reduce the size of postcss-selector-parser when bundled for the browser from 58570 bytes (58.6kB) to 49337 bytes (49.3 kB) – a reduction of 9.23kB or 15.8% smaller.

To test this, I just did a basic Webpack+Terser bulid:

npm i -g webpack-cli terser
webpack --mode production --entry ./dist/index.js --output /tmp/tmp.js && terser -mc < /tmp/tmp.js | wc -c
alexander-akait commented 4 years ago

Thanks!

alexander-akait commented 4 years ago

Do we need patch release?

tedconn commented 4 years ago

@evilebottnawi that would be great, please!