Skip to content

Conversation

@nolanlawson
Copy link
Contributor

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
Copy link

Coverage Status

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

1 similar comment
@coveralls
Copy link

Coverage Status

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

@nolanlawson
Copy link
Contributor Author

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
Copy link
Collaborator

Thanks!

@alexander-akait
Copy link
Collaborator

Do we need patch release?

@alexander-akait alexander-akait merged commit c716dc1 into postcss:master Sep 15, 2020
@tedconn
Copy link

tedconn commented Sep 20, 2020

@evilebottnawi that would be great, please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants