Skip to content

Commit

Permalink
Merge branch 'master' into fix-cjs-files
Browse files Browse the repository at this point in the history
  • Loading branch information
Rush committed Apr 9, 2024
2 parents e14a676 + c531af9 commit da87ff0
Show file tree
Hide file tree
Showing 49 changed files with 16,044 additions and 10,828 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}]
],
"plugins": [
["@babel/plugin-proposal-class-properties", {"loose": true}]
["@babel/plugin-proposal-class-properties", {"loose": true}],
["@babel/plugin-proposal-private-methods", {"loose": true}]
]
}
23 changes: 9 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ name: main
on:
push:
branches:
- master
- master
pull_request:
jobs:
build-and-test:
strategy:
matrix:
node:
- '10'
- '12'
- '14'
node: [10.x, 12.x, 14.x, 16.x]
runs-on: ubuntu-latest
name: Tests on Node.js v${{ matrix.node }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -29,21 +26,19 @@ jobs:
- name: Build sources
run: npm run build

- name: Run tests with xvfb available
uses: GabrielBB/xvfb-action@v1
with:
run: npm run test
- name: Run tests
run: npm run test

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: "14.x"

- name: Download deps
uses: bahmutov/npm-install@v1
Expand Down
2 changes: 1 addition & 1 deletion .npm-upgrade.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"reason": "Current version of Webpack Dev Server doesn't work with v4"
}
}
}
}
86 changes: 80 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,93 @@ _Note: Gaps between patch versions are faulty, broken or test releases._

## UNRELEASED

## 4.10.1

* **Bug Fix**
* fix `this.handleValueChange.cancel()` is not a function ([#611](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/625) by [@life2015](https://github.com/life2015))

## 4.10.0

* **Improvement**
* Allows filtering the list of entrypoints ([#624](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/624) by [@chriskrogh](https://github.com/chriskrogh))

* **Internal**
* Make module much slimmer by replacing all `lodash.*` packages ([#612](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/612)) by [@sukkaw](https://github.com/sukkaw).

## 4.9.1

* **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).

* **Bug Fix**
* fix `analyzerMode: 'server'` on certain machines ([#611](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/611) by [@panbenson](https://github.com/panbenson))

## 4.9.0

* **Improvement**
* Display modules included in concatenated entry modules on Webpack 5 when "Show content of concatenated modules" is checked ([#602](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/602) by [@pgoldberg](https://github.com/pgoldberg))

## 4.8.0

* **Improvement**
* Support reading large (>500MB) stats.json files ([#423](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/423) by [@henry-alakazhang](https://github.com/henry-alakazhang))
* Improve search UX by graying out non-matches ([#554](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/554) by [@starpit](https://github.com/starpit))

* **Internal**
* Add Node.js v16.x to CI and update GitHub actions ([#539](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/539) by [@amareshsm](https://github.com/amareshsm))

## 4.7.0

* **New Feature**
* Add the ability to filter to displaying only initial chunks per entrypoint ([#519](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/519) by [@pas-trop-de-zele](https://github.com/pas-trop-de-zele))

## 4.6.1

* **Bug Fix**
* fix outputting different URL in cli mode ([#524](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/524) by [@southorange1228](https://github.com/southorange1228))

## 4.6.0

* **New Feature**
* Support outputting different URL in server mode ([#520](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/520) by [@southorange1228](https://github.com/southorange1228))
* Use deterministic chunk colors (#[501](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/501) by [@CreativeTechGuy](https://github.com/CreativeTechGuy))

## 4.5.0

* **Improvement**
* Stop publishing src folder to npm ([#478](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/478) by [@wood1986](https://github.com/wood1986))

* **Internal**
* Update some dependencies ([#448](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/448))
* Replace nightmare with Puppeteer ([#469](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/469) by [@valscion](https://github.com/valscion))
* Replace Mocha with Jest ([#470](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/470) by [@valscion](https://github.com/valscion))

## 4.4.2

* **Bug Fix**
* Fix failure with `compiler.outputFileSystem.constructor` being `undefined` ([#447](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/447) by [@kedarv](https://github.com/kedarv) and [@alexander-akait](https://github.com/alexander-akait))
* **NOTE:** This fix doesn't have added test coverage so the fix might break in future versions unless test coverage is added later.

## 4.4.1

* **Bug Fix**
* Fix missing module chunks ([#433](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/433) by [@deanshub](https://github.com/deanshub))

* **Internal**
* Fix tests timing out in CI ([#435](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/435) by [@deanshub](https://github.com/deanshub))
* Fix command in issue template ([#428](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/428) by [@cncolder](https://github.com/cncolder))

## 4.4.0

* **Improvement**
* Keep treemap labels visible during zooming animations for better user experience ([#414](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/414) by [@
stanislawosinski](https://github.com/stanislawosinski))
* Keep treemap labels visible during zooming animations for better user experience ([#414](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/414) by [@stanislawosinski](https://github.com/stanislawosinski))

* **Bug Fix**
* Don't show an empty tooltip when hovering over the FoamTree attribution group or between top-level groups ([#413](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/413) by [@
stanislawosinski](https://github.com/stanislawosinski))
* Don't show an empty tooltip when hovering over the FoamTree attribution group or between top-level groups ([#413](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/413) by [@stanislawosinski](https://github.com/stanislawosinski))

* **Internal**
* Upgrade FoamTree to version 3.5.0, replace vendor dependency with an NPM package ([#412](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/412) by [@
stanislawosinski](https://github.com/stanislawosinski))
* Upgrade FoamTree to version 3.5.0, replace vendor dependency with an NPM package ([#412](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/412) by [@stanislawosinski](https://github.com/stanislawosinski))

## 4.3.0

Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![downloads][downloads]][downloads-url]

Expand Down Expand Up @@ -58,7 +57,8 @@ new BundleAnalyzerPlugin(options?: object)
|:--:|:--:|:----------|
|**`analyzerMode`**|One of: `server`, `static`, `json`, `disabled`|Default: `server`. In `server` mode analyzer will start HTTP server to show bundle report. In `static` mode single HTML file with bundle report will be generated. In `json` mode single JSON file with bundle report will be generated. In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`. |
|**`analyzerHost`**|`{String}`|Default: `127.0.0.1`. Host that will be used in `server` mode to start HTTP server.|
|**`analyzerPort`**|`{Number}` or `auto`|Default: `8888`. Port that will be used in `server` mode to start HTTP server.|
|**`analyzerPort`**|`{Number}` or `auto`|Default: `8888`. Port that will be used in `server` mode to start HTTP server. If `analyzerPort` is `auto`, the operating system will assign an arbitrary unused port |
|**`analyzerUrl`**|`{Function}` called with `{ listenHost: string, listenHost: string, boundAddress: server.address}`. [server.address comes from Node.js](https://nodejs.org/api/net.html#serveraddress)| Default: `http://${listenHost}:${boundAddress.port}`. The URL printed to console with server mode.|
|**`reportFilename`**|`{String}`|Default: `report.html`. Path to bundle report file that will be generated in `static` mode. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|
|**`reportTitle`**|`{String\|function}`|Default: function that returns pretty printed current date and time. Content of the HTML `title` element; or a function of the form `() => string` that provides the content.|
|**`defaultSizes`**|One of: `stat`, `parsed`, `gzip`|Default: `parsed`. Module sizes to show in report by default. [Size definitions](#size-definitions) section describes what these values mean.|
Expand Down Expand Up @@ -173,8 +173,8 @@ The Chunk Context Menu can be opened by right-clicking or `Ctrl`-clicking on a s

It happens when `webpack-bundle-analyzer` analyzes files that don't actually exist in your file system, for example when you work with `webpack-dev-server` that keeps all the files in RAM. If you use `webpack-bundle-analyzer` as a plugin you won't get any errors, however if you run it via CLI you get the error message in terminal:
```
Couldn't parse bundle asset "your_bundle_name.bundle.js".
Analyzer will use module sizes from stats file.
Error parsing bundle asset "your_bundle_name.bundle.js": no such file
No bundles were parsed. Analyzer will show only original module sizes from stats file.
```
To get more information about it you can read [issue #147](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/147).

Expand Down Expand Up @@ -210,9 +210,6 @@ To get more information about it you can read [issue #147](https://github.com/we
[node]: https://img.shields.io/node/v/webpack-bundle-analyzer.svg
[node-url]: https://nodejs.org

[deps]: https://david-dm.org/webpack-contrib/webpack-bundle-analyzer.svg
[deps-url]: https://david-dm.org/webpack-contrib/webpack-bundle-analyzer

[tests]: http://img.shields.io/travis/webpack-contrib/webpack-bundle-analyzer.svg
[tests-url]: https://travis-ci.org/webpack-contrib/webpack-bundle-analyzer

Expand Down
24 changes: 24 additions & 0 deletions client/components/Dropdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.container {
font: var(--main-font);
white-space: nowrap;
}

.label {
font-size: 11px;
font-weight: bold;
margin-bottom: 7px;
}

.input {
border: 1px solid #aaa;
border-radius: 4px;
display: block;
width: 100%;
color: #7f7f7f;
height: 27px;
}

.option {
padding: 4px 0;
cursor: pointer;
}
88 changes: 88 additions & 0 deletions client/components/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {createRef} from 'preact';
import PureComponent from '../lib/PureComponent';

import s from './Dropdown.css';

export default class Dropdown extends PureComponent {
input = createRef();

state = {
query: '',
showOptions: false
};

componentDidMount() {
document.addEventListener('click', this.handleClickOutside, true);
}

componentWillUnmount() {
document.removeEventListener('click', this.handleClickOutside, true);
}

render() {
const {label, options} = this.props;

const filteredOptions =
this.state.query
? options.filter((option) =>
option.toLowerCase().includes(this.state.query.toLowerCase())
)
: options;

return (
<div className={s.container}>
<div className={s.label}>{label}:</div>
<div>
<input ref={this.input}
className={s.input}
type="text"
value={this.state.query}
onInput={this.handleInput}
onFocus={this.handleFocus}/>
{this.state.showOptions ? (
<div className={s.options}>
{filteredOptions.map((option) => (
<div key={option}
className={s.option}
onClick={this.getOptionClickHandler(option)}>
{option}
</div>
))}
</div>
) : null}
</div>
</div>
);
}

handleClickOutside = (event) => {
const el = this.input.current;
if (el && event && !el.contains(event.target)) {
this.setState({showOptions: false});
// If the query is not in the options, reset the selection
if (this.state.query && !this.props.options.some((option) => option === this.state.query)) {
this.setState({query: ''});
this.props.onSelectionChange(undefined);
}
}
};

handleInput = (event) => {
const {value} = event.target;
this.setState({query: value});
if (!value) {
this.props.onSelectionChange(undefined);
}
}

handleFocus = () => {
// move the cursor to the end of the input
this.input.current.value = this.state.query;
this.setState({showOptions: true});
}

getOptionClickHandler = (option) => () => {
this.props.onSelectionChange(option);
this.setState({query: option, showOptions: false});
};
}
16 changes: 9 additions & 7 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 'html-escaper';
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,22 +59,23 @@ 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;
}

get invisibleHint() {
return `${_.upperFirst(this.itemType)} is not rendered in the treemap because it's too small.`;
const itemType = this.itemType.charAt(0).toUpperCase() + this.itemType.slice(1);
return `${itemType} is not rendered in the treemap because it's too small.`;
}

get isVisible() {
Expand Down

0 comments on commit da87ff0

Please sign in to comment.