Skip to content

Version 3 #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d1ca51e
Use MobX for state management
th0r Aug 26, 2018
4fa59d3
Remove Opera from Babel Env config
th0r Aug 26, 2018
bdf69e3
Use ES6 MobX bundle
th0r Aug 26, 2018
e1dbfa8
Upgrade to Webpack 4
th0r Aug 26, 2018
b06d739
Highlight found modules
th0r Aug 27, 2018
9c0ef23
Use `useBuiltIns: 'usage'` option instead of 'entry'
th0r Aug 27, 2018
bce1c31
- Sorting of found modules
th0r Aug 28, 2018
38036cf
Update deps
th0r Aug 28, 2018
981db6e
Set Node.js 6 as compilation target for Babel
th0r Aug 28, 2018
1e3f5f7
Fix parsing of decorators in ESLint
th0r Aug 29, 2018
d45dba8
Fix .gitignore file
th0r Aug 29, 2018
598b41b
Fix ModuleConcatenation bailout for some modules
th0r Aug 29, 2018
0f9d03a
Increase initial sidebar hiding timeout to 3 seconds
th0r Aug 29, 2018
35c4d06
Add icons to modules list
th0r Aug 29, 2018
c637c14
Use global CSS variables
th0r Aug 29, 2018
7dc167a
Add "Escape" key handler instead of "Clear search" button
th0r Aug 29, 2018
5e1e932
Autofocus search field
th0r Aug 29, 2018
7c58136
Bring back "clear search" button
th0r Aug 30, 2018
22f356b
Update `eslint-plugin-th0r-react`
th0r Aug 30, 2018
d3e5f79
Update deps
th0r Aug 30, 2018
2dabaa1
Implement merging of nested folders
th0r Aug 30, 2018
d8a4a86
Properly zoom to not rendered (too small) modules
th0r Sep 5, 2018
58f0e52
Group found modules by chunk
th0r Sep 5, 2018
29673be
Update treemap library
th0r Sep 8, 2018
a856a66
Improve search UX
th0r Sep 8, 2018
2ef50a9
Preserve copyright comments in client bundle
th0r Sep 8, 2018
96ea483
Add toggle button for the sidebar
th0r Sep 8, 2018
bba3fca
Add pinning functionality to sidebar
th0r Sep 9, 2018
faedb2b
Update package-lock.json
th0r Sep 10, 2018
ca7a75c
Fix keydown handler in `Search` component
th0r Sep 10, 2018
43678a1
Add icon for sidebar toggle button
th0r Sep 10, 2018
babf297
Add icon for sidebar pin button
th0r Sep 10, 2018
121aa87
Set `min-width` to sidebar
th0r Sep 10, 2018
ede606d
Make button hover background opaque
th0r Sep 11, 2018
8e70fbd
Add option to show content of concatenated modules
th0r Sep 11, 2018
cc2cd0f
Use `display: inline-block` for checkbox labels
th0r Sep 11, 2018
1ff4c00
Update deps
th0r Sep 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
// Compiles sources, gulpfile and tests
{
"presets": [
["env", {
"targets": { "node": 4 },
"exclude": [
// Node 4 supports all the generator features that we use so there is no need in Regenerator
"transform-regenerator"
]
["@babel/preset-env", {
"targets": {"node": 6}
}]
],
"plugins": [
["transform-object-rest-spread", { "useBuiltIns": true }],
"transform-class-properties"
["@babel/plugin-proposal-class-properties", {"loose": true}],
"@babel/plugin-transform-runtime"
]
}
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"root": true,
"extends": "th0r",
"rules": {
"object-curly-spacing": ["error", "always"]
}
"extends": "th0r"
}
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ new BundleAnalyzerPlugin({
generateStatsFile: true,
// Excludes module sources from stats file so there won't be any sensitive data
statsOptions: { source: false }
})`
})
```
`stats.json` will be created in Webpack bundle output directory.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lib
public
samples
/lib
/public
/samples
node_modules
npm-debug.log
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ branches:
only:
- master
node_js:
- "4"
- "6"
- "8"
- "node"
cache:
- yarn: true
- directories:
- node_modules
addons:
Expand Down
16 changes: 5 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@ To contribute to `webpack-bundle-analyzer`, fork the repository and clone it to

## Setup packages

Then install [`yarn`](https://yarnpkg.com/):
Next, install this package's dependencies:

```sh
npm install --global yarn
```

Next, install this package's dependencies with `yarn`:

```sh
yarn install
npm i
```

## Develop with your own project

Run the following to build this library and watch its source files for changes:

```sh
yarn run start
npm run start
```

You will now have a fully functioning local build of this library ready to be used. **Leave the `start` script running**, and continue with a new Terminal/shell window.
Expand Down Expand Up @@ -73,11 +67,11 @@ After these steps, you should be able to create a new Pull Request for this repo
It would be really great if the changes you did could be tested somehow. Our tests live inside the `test` directory, and they can be run with the following command:

```sh
yarn run test-dev
npm run test-dev
```

Now whenever you change some files, the tests will be rerun immediately. If you don't want that, and want to run tests as a one-off operation, you can use:

```sh
yarn run test
npm test
```
11 changes: 10 additions & 1 deletion client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
"extends": [
"th0r-react",
"../.eslintrc.json"
]
],
"parserOptions": {
"ecmaFeatures": {
"legacyDecorators": true
}
},
"rules": {
"react/jsx-key": "off",
"react/jsx-no-bind": "off"
}
}
1 change: 1 addition & 0 deletions client/assets/icon-arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/assets/icon-chunk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/assets/icon-folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/assets/icon-invisible.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/assets/icon-module.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/assets/icon-pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions client/components/Button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.button {
background: #fff;
border: 1px solid #aaa;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font: var(--main-font);
outline: none;
padding: 5px 7px;
transition: background .3s ease;
white-space: nowrap;
}

.button:focus,
.button:hover {
background: #ffefd7;
}

.button.active {
background: #ffa500;
color: #000;
}

.button[disabled] {
cursor: default;
}
41 changes: 41 additions & 0 deletions client/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @jsx h */
import {h} from 'preact';
import cls from 'classnames';
import s from './Button.css';
import PureComponent from '../lib/PureComponent';

export default class Button extends PureComponent {
render({active, toggle, className, children, ...props}) {
const classes = cls(className, {
[s.button]: true,
[s.active]: active,
[s.toggle]: toggle
});

return (
<button {...props}
ref={this.saveRef}
type="button"
className={classes}
disabled={this.disabled}
onClick={this.handleClick}>
{children}
</button>
);
}

get disabled() {
const {props} = this;
return (
props.disabled ||
(props.active && !props.toggle)
);
}

handleClick = (event) => {
this.elem.blur();
this.props.onClick(event);
}

saveRef = elem => this.elem = elem;
}
15 changes: 15 additions & 0 deletions client/components/Checkbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.label {
cursor: pointer;
display: block;
}

.checkbox {
cursor: pointer;
}

.itemText {
margin-left: 3px;
position: relative;
top: -2px;
vertical-align: middle;
}
29 changes: 29 additions & 0 deletions client/components/Checkbox.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/** @jsx h */
import {h, Component} from 'preact';
import cls from 'classnames';

import s from './Checkbox.css';

export default class Checkbox extends Component {

render() {
const {checked, className, children} = this.props;

return (
<label className={cls(s.label, className)}>
<input className={s.checkbox}
type="checkbox"
checked={checked}
onChange={this.handleChange}/>
<span className={s.itemText}>
{children}
</span>
</label>
);
}

handleChange = () => {
this.props.onChange(!this.props.checked);
}

}
19 changes: 1 addition & 18 deletions client/components/CheckboxList.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.container {
font: normal 10px Verdana;
font: var(--main-font);
white-space: nowrap;
}

Expand All @@ -8,20 +8,3 @@
font-weight: bold;
margin-bottom: 7px;
}

.checkbox {
cursor: pointer;
}

.item {
cursor: pointer;
display: block;
margin-bottom: 3px;
}

.itemText {
margin-left: 3px;
position: relative;
top: -2px;
vertical-align: middle;
}
15 changes: 8 additions & 7 deletions client/components/CheckboxList.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/** @jsx h */
import { h, Component } from 'preact';
import {h} from 'preact';

import CheckboxListItem from './CheckboxListItem';
import s from './CheckboxList.css';
import PureComponent from '../lib/PureComponent';

const ALL_ITEM = Symbol('ALL_ITEM');

export default class CheckboxList extends Component {
export default class CheckboxList extends PureComponent {

static ALL_ITEM = ALL_ITEM;

Expand All @@ -21,22 +22,22 @@ export default class CheckboxList extends Component {
if (newProps.items !== this.props.items) {
if (this.isAllChecked()) {
// Preserving `all checked` state
this.setState({ checkedItems: newProps.items });
this.setState({checkedItems: newProps.items});
this.informAboutChange(newProps.items);
} else if (this.state.checkedItems.length) {
// Checking only items that are in the new `items` array
const checkedItems = newProps.items.filter(item =>
this.state.checkedItems.find(checkedItem => checkedItem.label === item.label)
);

this.setState({ checkedItems });
this.setState({checkedItems});
this.informAboutChange(checkedItems);
}
}
}

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

return (
<div className={s.container}>
Expand Down Expand Up @@ -64,7 +65,7 @@ export default class CheckboxList extends Component {

handleToggleAllCheck = () => {
const checkedItems = this.isAllChecked() ? [] : this.props.items;
this.setState({ checkedItems });
this.setState({checkedItems});
this.informAboutChange(checkedItems);
};

Expand All @@ -77,7 +78,7 @@ export default class CheckboxList extends Component {
checkedItems = [...this.state.checkedItems, item];
}

this.setState({ checkedItems });
this.setState({checkedItems});
this.informAboutChange(checkedItems);
};

Expand Down
26 changes: 8 additions & 18 deletions client/components/CheckboxListItem.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
/** @jsx h */
import { h, Component } from 'preact';
import {h, Component} from 'preact';

import Checkbox from './Checkbox';
import CheckboxList from './CheckboxList';

import s from './CheckboxList.css';

export default class CheckboxListItem extends Component {

render() {
const { checked } = this.props;

return (
<label className={s.item}>
<input className={s.checkbox}
type="checkbox"
checked={checked}
onChange={this.handleChange}/>
<Checkbox {...this.props}
onChange={this.handleChange}>
{this.renderLabel()}
</label>
</Checkbox>
);
}

renderLabel() {
const { children, item } = this.props;
const {children, item} = this.props;

if (children && children.length) {
return children[0](item, s.itemText);
return children[0](item);
}

return (
<span className={s.itemText}>
{item === CheckboxList.ALL_ITEM ? 'All' : item.label}
</span>
);
return (item === CheckboxList.ALL_ITEM) ? 'All' : item.label;
}

handleChange = () => {
Expand Down
4 changes: 4 additions & 0 deletions client/components/Icon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.icon {
background: no-repeat center/contain;
display: inline-block;
}
Loading