Skip to content

Commit

Permalink
Reduce installation size (#609)
Browse files Browse the repository at this point in the history
* Replace `chalk` with `picocolors`

* Replace `lodash` with individual modules

* Fix Node.js 10 compatability

* Replace `lodash.escaperegexp` with `escape-string-regexp`

* Add missing comment back

* Update Changelog
  • Loading branch information
SukkaW committed Aug 3, 2023
1 parent e120231 commit e2a6479
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ _Note: Gaps between patch versions are faulty, broken or test releases._

* **Internal**
* Replace some lodash usages with JavaScript native API ([#505](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/505)) by [@sukkaw](https://github.com/sukkaw).
* Make module much slimmer ([#609](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/609)) by [@sukkaw](https://github.com/sukkaw).

## 4.9.0

Expand Down
13 changes: 7 additions & 6 deletions client/components/ModuleItem.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import escapeRegExp from 'escape-string-regexp';
import escape from 'lodash.escape';
import filesize from 'filesize';
import cls from 'classnames';

Expand Down Expand Up @@ -47,7 +48,7 @@ export default class ModuleItem extends PureComponent {
if (term) {
const regexp = (term instanceof RegExp) ?
new RegExp(term.source, 'igu') :
new RegExp(`(?:${_.escapeRegExp(term)})+`, 'iu');
new RegExp(`(?:${escapeRegExp(term)})+`, 'iu');
let match;
let lastMatch;

Expand All @@ -58,15 +59,15 @@ export default class ModuleItem extends PureComponent {

if (lastMatch) {
html = (
_.escape(title.slice(0, lastMatch.index)) +
`<strong>${_.escape(lastMatch[0])}</strong>` +
_.escape(title.slice(lastMatch.index + lastMatch[0].length))
escape(title.slice(0, lastMatch.index)) +
`<strong>${escape(lastMatch[0])}</strong>` +
escape(title.slice(lastMatch.index + lastMatch[0].length))
);
}
}

if (!html) {
html = _.escape(title);
html = escape(title);
}

return html;
Expand Down
4 changes: 2 additions & 2 deletions client/components/Search.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import debounce from 'lodash.debounce';

import s from './Search.css';
import Button from './Button';
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class Search extends PureComponent {
);
}

handleValueChange = _.debounce((event) => {
handleValueChange = debounce((event) => {
this.informChange(event.target.value);
}, 400)

Expand Down

0 comments on commit e2a6479

Please sign in to comment.