-
-
Notifications
You must be signed in to change notification settings - Fork 489
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
Version 3: Split reporting UI from dependency graph size calculation #97
Closed
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
bed16d6
Trim trailing whitespace in analyzer bin
valscion 92725f7
Move chartData calculation to outer layer of code
valscion 013cec6
Pass logger instance form bin to viewer
valscion 6324701
Force the presence of logger in viewer functions
valscion 8a78d1b
Force the presence of logger in analyzer functions
valscion 7484107
Move client and views directories under reporter root directory
valscion 1887ecb
Remove start from main entry point
valscion 14068fa
Update changelog with unreleased changes
valscion 59c3926
Update package.json files array to match reporter changes
valscion 4f405cf
Merge branch 'master' into split-reporter-2
valscion 318f588
Merge pull request #81 from th0r/split-reporter-2
valscion 0dea700
Run lerna init
valscion d218b3e
Move code-related files 1:1 under packages/webpack-bundle-analyzer-pl…
valscion 9d2e4d3
Add root-level package.json
valscion 88c4256
Configure lerna to use yarn as npm client
valscion 3d4f895
Move lerna dep to root-level package.json
valscion 2cb55a6
Use exact version for lerna
valscion e579dad
Run yarn in root of repo
valscion 31b443b
Add some info about lerna to CONTRIBUTING.md
valscion a18dc45
Split Treemap reporter to new package
valscion 14b6356
Update .gitignore to work with monorepo
valscion aab16e4
Move linting setup to root level
valscion c6afe54
Run bootstrap in CI
valscion 8af93ed
Replace global lerna usage instruction with npm script
valscion 2ae76b4
Cache sub-package node_modules in TravisCI as well
valscion 0c7403f
v3.0.0-alpha.0
valscion ad1304f
Merge pull request #98 from th0r/lerna
valscion b45c783
Fix .gitignore being too eager
valscion a62bcad
Merge pull request #99 from th0r/fix-git-ignore
valscion dcd2336
Point URLs in reporter-treemap package.json to main repo
valscion d7c74f1
Remove unnecessary reporter/ subdir in reporter package
valscion 2b96d9a
Remove obsolete reporter-related package.json/files setup in plugin
valscion c259b77
Merge pull request #100 from th0r/clean-up-reporter
valscion 5806437
Add npm run dev script
valscion b7906da
Move publish script to root package
valscion 560339d
Stream output of tests while running
valscion 5ffe9d9
Merge pull request #101 from th0r/improve-dev-experience
valscion 6de3a6b
Move plugin code to @webpack-bundle-analyzer/plugin npm package
valscion a8d8b91
Run yarn in every package
valscion f6d99c0
v3.0.0-alpha.1
valscion 1826eae
Remove deprecated startAnalyzer plugin option
valscion 1498e7c
Add --reporter and --reporterOptions to configure reporter
valscion 82780ca
Add test-dev npm script
valscion e989f78
Define static report output path on the outer edge
valscion 1d97eec
Move process.cwd() fallback for outputPath to plugin
valscion ebf60e7
Always set CLI outputPath as current working directory
valscion a72fccd
Remove outputPath fallback from plugin code
valscion e3a70d5
Fix test invocations
valscion e73619d
Remove unnecessary tmp directory setup for dev-server tests
valscion fec9b6d
Merge pull request #102 from th0r/new-options
valscion d4e1915
Merge master to version-3 branch to bring it up-to-date (#117)
valscion 17ef047
Merge branch 'master' into version-3
valscion b881a78
Upgrade lerna to v2.2.0
valscion 11a930e
Point nightmare package to a version that pins electron
valscion e4440a0
Configure lerna and yarn to use workspaces
valscion 214d7cb
Remove yarn.lock from sub-deps to have it only on root level
valscion 2cefa35
Configure Travis to use [email protected]
valscion 9bc8b43
Merge pull request #118 from th0r/yarn-workspaces-and-version-1
valscion 6e02730
Merge commit 'ce41c97' into version-3
valscion 57b341f
Merge commit 'e6fbbe7' into version-3
valscion 40c06e7
Merge commit 'ceef5be' into version-3
valscion 082bb9a
Merge branch 'master' into version-3
valscion d73ea19
Merge branch 'master' into version-3
valscion 9ea963d
Setup viewer specific tests properly
valscion acbc837
Merge commit '5cb03bad2195506189c2cefedbf601fd5d3252f7' into version-3
valscion 282c1e1
Merge branch 'master' into version-3
valscion 61dabf9
Run CI for pull requests targeting version-3 branch
valscion faf24a3
Split bundle parsing to new package (#143)
valscion 15caf72
Extract Logger class to own package (#151)
valscion 241f500
v3.0.0-alpha.2
valscion b63ca72
Fix bundle-parser README.md API example
valscion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
# node_modules in sub-packages | ||
packages/*/node_modules | ||
|
||
# Generated code | ||
lib | ||
public | ||
packages/*/lib | ||
packages/reporter-treemap/public | ||
|
||
# Vendor code | ||
client/vendor | ||
packages/reporter-treemap/client/vendor | ||
|
||
# Test fixtures | ||
test/bundles | ||
test/webpack.config.js | ||
packages/*/test/bundles | ||
packages/*/test/webpack.config.js | ||
|
||
# Test results | ||
test/output | ||
packages/*/test/output | ||
|
||
samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
lib | ||
public | ||
# node_modules in sub-packages | ||
packages/*/node_modules | ||
|
||
# Generated code | ||
packages/*/lib | ||
packages/reporter-treemap/public | ||
|
||
samples | ||
|
||
node_modules | ||
npm-debug.log | ||
lerna-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"lerna": "2.0.0", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"version": "3.0.0-alpha.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,23 @@ | ||
{ | ||
"name": "webpack-bundle-analyzer", | ||
"version": "2.10.0", | ||
"description": "Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap", | ||
"author": "Yury Grunin <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/webpack-contrib/webpack-bundle-analyzer", | ||
"changelog": "https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CHANGELOG.md", | ||
"bugs": { | ||
"url": "https://github.com/webpack-contrib/webpack-bundle-analyzer/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/webpack-contrib/webpack-bundle-analyzer.git" | ||
}, | ||
"main": "lib/index.js", | ||
"bin": "lib/bin/analyzer.js", | ||
"engines": { | ||
"node": ">= 4" | ||
}, | ||
"scripts": { | ||
"start": "gulp watch", | ||
"build": "gulp build", | ||
"npm-publish": "npm run lint && npm run build && npm test && npm publish", | ||
"lint": "eslint --ext js,jsx .", | ||
"test": "mocha --exit --require babel-core/register", | ||
"test-dev": "mocha --watch --require babel-core/register" | ||
}, | ||
"files": [ | ||
"public", | ||
"lib", | ||
"src", | ||
"views" | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"dependencies": { | ||
"acorn": "^5.3.0", | ||
"bfj-node4": "^5.2.0", | ||
"chalk": "^2.3.0", | ||
"commander": "^2.13.0", | ||
"ejs": "^2.5.7", | ||
"express": "^4.16.2", | ||
"filesize": "^3.5.11", | ||
"gzip-size": "^4.1.0", | ||
"lodash": "^4.17.4", | ||
"mkdirp": "^0.5.1", | ||
"opener": "^1.4.3", | ||
"ws": "^4.0.0" | ||
"scripts": { | ||
"bootstrap": "lerna bootstrap", | ||
"build": "lerna run build --stream", | ||
"dev": "lerna run start --parallel", | ||
"npm-publish": "npm run lint && npm run build && npm test && lerna publish", | ||
"test": "lerna run test --stream", | ||
"test-dev": "lerna run test-dev --parallel", | ||
"lint": "eslint --ext js,jsx ." | ||
}, | ||
"devDependencies": { | ||
"babel-core": "6.26.0", | ||
"babel-eslint": "8.2.1", | ||
"babel-loader": "7.1.2", | ||
"babel-plugin-transform-class-properties": "6.24.1", | ||
"babel-plugin-transform-object-rest-spread": "6.26.0", | ||
"babel-plugin-transform-react-jsx": "6.24.1", | ||
"babel-preset-env": "1.6.1", | ||
"chai": "4.1.2", | ||
"chai-subset": "1.6.0", | ||
"classnames": "2.2.5", | ||
"css-loader": "0.28.9", | ||
"del": "3.0.0", | ||
"eslint": "4.16.0", | ||
"eslint-config-th0r": "1.0.0", | ||
"eslint-config-th0r-react": "1.0.0", | ||
"eslint-plugin-react": "7.6.1", | ||
"exports-loader": "0.6.4", | ||
"gulp": "4.0.0", | ||
"gulp-babel": "7.0.1", | ||
"mocha": "5.0.0", | ||
"nightmare": "2.10.0", | ||
"preact": "8.2.7", | ||
"sinon": "4.2.2", | ||
"stream-combiner2": "1.1.1", | ||
"style-loader": "0.20.1", | ||
"webpack": "3.10.0", | ||
"webpack-dev-server": "2.11.1" | ||
}, | ||
"keywords": [ | ||
"webpack", | ||
"bundle", | ||
"analyzer", | ||
"modules", | ||
"size", | ||
"interactive", | ||
"chart", | ||
"treemap", | ||
"zoomable", | ||
"zoom" | ||
] | ||
"lerna": "2.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Babel config for Node | ||
// 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" | ||
] | ||
}] | ||
], | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<div align="center"> | ||
<a href="https://github.com/webpack/webpack"> | ||
<img width="200" height="200" | ||
src="https://webpack.js.org/assets/icon-square-big.svg"> | ||
</a> | ||
<h1>@webpack-bundle-analyzer/bundle-parser</h1> | ||
<p>Calculates module sizes from webpack output files.</p> | ||
</div> | ||
|
||
<h2 align="center">Install</h2> | ||
|
||
```bash | ||
npm install --save @webpack-bundle-analyzer/bundle-parser | ||
``` | ||
|
||
<h2 align="center">Usage</h2> | ||
|
||
```js | ||
const parseBundle = require('@webpack-bundle-analyzer/bundle-parser'); | ||
const Logger = require('@webpack-bundle-analyzer/logger'); | ||
|
||
const fs = require('fs'); | ||
const webpackStats = JSON.parse( | ||
fs.readFileSync('webpack/output/path/stats.json', 'utf8') | ||
); | ||
|
||
const moduleSizeData = parseBundle( | ||
webpackStats, | ||
'webpack/output/path', | ||
{ logger: new Logger('info') } | ||
); | ||
|
||
console.log(JSON.stringify(moduleSizeData, null, 2)); | ||
``` | ||
|
||
Example output: | ||
|
||
```json | ||
[ | ||
{ | ||
"label": "bundle.js", | ||
"statSize": 141, | ||
"parsedSize": 445, | ||
"gzipSize": 178, | ||
"groups": [ | ||
{ | ||
"label": "my-app", | ||
"path": "./my-app", | ||
"statSize": 141, | ||
"parsedSize": 332, | ||
"gzipSize": 119, | ||
"groups": [ | ||
{ | ||
"label": "src", | ||
"path": "./my-app/src", | ||
"statSize": 141, | ||
"parsedSize": 332, | ||
"gzipSize": 119, | ||
"groups": [ | ||
{ | ||
"id": 0, | ||
"label": "index.js", | ||
"path": "./my-app/src/index.js", | ||
"statSize": 54, | ||
"parsedSize": 131, | ||
"gzipSize": 93 | ||
}, | ||
{ | ||
"id": 1, | ||
"label": "a.js", | ||
"path": "./my-app/src/a.js", | ||
"statSize": 29, | ||
"parsedSize": 67, | ||
"gzipSize": 73 | ||
}, | ||
{ | ||
"id": 2, | ||
"label": "b.js", | ||
"path": "./my-app/src/b.js", | ||
"statSize": 29, | ||
"parsedSize": 67, | ||
"gzipSize": 73 | ||
}, | ||
{ | ||
"id": 3, | ||
"label": "a-clone.js", | ||
"path": "./my-app/src/a-clone.js", | ||
"statSize": 29, | ||
"parsedSize": 67, | ||
"gzipSize": 73 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
|
||
<h2 align="center">Options</h2> | ||
|
||
```js | ||
parseBundle( | ||
bundleStats: object, | ||
bundleDir: string, | ||
options: { | ||
logger: Logger | ||
} | ||
); | ||
``` | ||
|
||
|Name|Type|Description| | ||
|:--:|:--:|:----------| | ||
|**`bundleStats`**|`{Object}`|webpack compilation information as a JSON object. This is the output of [`stats.toJson()`](https://webpack.js.org/api/node/#stats-tojson-options-) webpack Node.js API.| | ||
|**`bundleDir`**|`{String}`|Path to directory containing webpack output files, i.e. the value of [`output.path` webpack config](https://webpack.js.org/configuration/output/#output-path).| | ||
|**`options.logger`**|`{Logger}`|An instance of a special `Logger` class also used in `webpack-bundle-analyzer`.| | ||
|
||
|
||
|
||
<h2 align="center" id="size-definitions">Size definitions</h2> | ||
|
||
Data contains three sizes for each module if bundle parsing has succeeded, or only `statSize` if bundle parsing has failed for some reason. | ||
|
||
### `statSize` | ||
|
||
The "input" size of modules, before any transformations like minification. | ||
|
||
### `parsedSize` | ||
|
||
The "output" size of modules. If you're using a webpack plugin such as Uglify, then this value will reflect the minified size of your code. | ||
|
||
### `gzipSize` | ||
|
||
Size approximation of running the parsed modules through gzip compression. | ||
|
||
Gzip sizes of folders are calculated by concatenating the parsed sources of all modules inside a folder and running [`gzip-size`](https://github.com/sindresorhus/gzip-size) over it. | ||
|
||
|
||
<h2 align="center">Troubleshooting</h2> | ||
|
||
### Some inner modules are missing from the data | ||
|
||
This is a known caveat when `webpack.optimize.ModuleConcatenationPlugin` is used. The way `ModuleConcatenationPlugin` works is that it merges multiple modules into a single one, and so that resulting module doesn't have edges anymore. | ||
|
||
If you are interested to drill down to exact dependencies, try parsing output without `ModuleConcatenationPlugin` applied. See [issue #115](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/115) for more discussion. | ||
|
||
<h2 align="center">Maintainers</h2> | ||
|
||
<table> | ||
<tbody> | ||
<tr> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://avatars3.githubusercontent.com/u/302213?v=4&s=150"> | ||
</br> | ||
<a href="https://github.com/th0r">Yuriy Grunin</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://avatars3.githubusercontent.com/u/482561?v=4&s=150"> | ||
</br> | ||
<a href="https://github.com/valscion">Vesa Laakso</a> | ||
</td> | ||
</tr> | ||
<tbody> | ||
</table> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be removed right before merging. This is needed here so that branches against this
version-3
branch have their tests ran in CI. See #143 (comment)