Skip to content

Commit

Permalink
Merge pull request #98 from th0r/lerna
Browse files Browse the repository at this point in the history
Setup Lerna monorepo, splitting reporter to new package
  • Loading branch information
valscion committed Jul 14, 2017
2 parents 318f588 + 0c7403f commit ad1304f
Show file tree
Hide file tree
Showing 81 changed files with 10,881 additions and 4,654 deletions.
15 changes: 9 additions & 6 deletions .eslintignore
@@ -1,15 +1,18 @@
# node_modules in sub-packages
packages/*/node_modules

# Generated code
lib
public
packages/*/lib
packages/reporter-treemap/reporter/public

# Vendor code
reporter/client/vendor
packages/reporter-treemap/reporter/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
21 changes: 19 additions & 2 deletions .gitignore
@@ -1,5 +1,22 @@
lib
public
# node_modules in sub-packages
packages/*/node_modules

# Generated code
packages/*/lib
packages/reporter-treemap/reporter/public

# Vendor code
packages/reporter-treemap/reporter/client/vendor

# Test fixtures
packages/*/test/bundles
packages/*/test/webpack.config.js

# Test results
packages/*/test/output

samples

node_modules
npm-debug.log
lerna-debug.log
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,8 @@ cache:
- yarn: true
- directories:
- node_modules
- packages/reporter-treemap/node_modules
- packages/webpack-bundle-analyzer/node_modules
env:
# Required to compile native modules for Node.js v4+
# See https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Node.js-v4-(or-io.js-v3)-compiler-requirements
Expand All @@ -23,6 +25,8 @@ addons:
# Required to compile native modules for Node.js v4+
- g++-4.8
before_script:
# Install packages in subdirectories
- npm run bootstrap
# Required by Electron
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
Expand Down
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -4,7 +4,7 @@ To contribute to `webpack-bundle-analyzer`, fork the repository and clone it to

## Setup packages

Then install [`yarn`](https://yarnpkg.com/):
Install [`yarn`](https://yarnpkg.com/):

```sh
npm install --global yarn
Expand All @@ -16,6 +16,12 @@ Next, install this package's dependencies with `yarn`:
yarn install
```

Bootstrap the Lerna project (installs all node_modules in monorepo packages)

```sh
npm run bootstrap
```

## Develop with your own project

Run the following to build this library and watch its source files for changes:
Expand Down
8 changes: 8 additions & 0 deletions lerna.json
@@ -0,0 +1,8 @@
{
"lerna": "2.0.0",
"npmClient": "yarn",
"packages": [
"packages/*"
],
"version": "3.0.0-alpha.0"
}
89 changes: 7 additions & 82 deletions package.json
@@ -1,90 +1,15 @@
{
"name": "webpack-bundle-analyzer",
"version": "2.8.3",
"description": "Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap",
"author": "Yury Grunin <grunin.ya@ya.ru>",
"license": "MIT",
"homepage": "https://github.com/th0r/webpack-bundle-analyzer",
"changelog": "https://github.com/th0r/webpack-bundle-analyzer/blob/master/CHANGELOG.md",
"bugs": {
"url": "https://github.com/th0r/webpack-bundle-analyzer/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/th0r/webpack-bundle-analyzer.git"
},
"main": "lib/index.js",
"bin": "lib/bin/analyzer.js",
"engines": {
"node": ">= 4"
},
"private": true,
"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 --compilers js:babel-core/register",
"test-dev": "mocha --watch --compilers js:babel-core/register"
},
"files": [
"lib",
"reporter/public",
"reporter/views",
"src"
],
"dependencies": {
"acorn": "^5.1.1",
"chalk": "^1.1.3",
"commander": "^2.9.0",
"ejs": "^2.5.6",
"express": "^4.15.2",
"filesize": "^3.5.9",
"gzip-size": "^3.0.0",
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"opener": "^1.4.3",
"ws": "^2.3.1"
"bootstrap": "lerna bootstrap",
"build": "lerna run build --stream",
"test": "lerna run test",
"lint": "eslint --ext js,jsx ."
},
"devDependencies": {
"babel-core": "6.24.1",
"babel-eslint": "7.2.3",
"babel-loader": "7.0.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"babel-plugin-transform-react-jsx": "6.24.1",
"babel-preset-env": "1.4.0",
"chai": "3.5.0",
"chai-subset": "1.5.0",
"classnames": "2.2.5",
"css-loader": "0.28.1",
"del": "2.2.2",
"eslint": "3.19.0",
"eslint-plugin-react": "7.0.0",
"exports-loader": "0.6.4",
"gulp": "3.9.1",
"gulp-babel": "6.1.2",
"gulp-plumber": "1.1.0",
"gulp-util": "3.0.8",
"gulp-watch": "4.3.11",
"mocha": "3.3.0",
"nightmare": "2.10.0",
"preact": "8.1.0",
"sinon": "2.2.0",
"stream-combiner2": "1.1.1",
"style-loader": "0.17.0",
"webpack": "2.5.1",
"webpack-dev-server": "2.4.5"
},
"keywords": [
"webpack",
"bundle",
"analyzer",
"modules",
"size",
"interactive",
"chart",
"treemap",
"zoomable",
"zoom"
]
"lerna": "2.0.0"
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions packages/reporter-treemap/README.md
@@ -0,0 +1 @@
This is the treemap reporter.
Expand Up @@ -10,10 +10,9 @@ const NODE_DEST = resolve('lib');
const cli = require('commander')
.usage('<task> [options]')
.option('-e, --env <environment>', 'Can be `prod` or `dev`. Default is `dev`', /^(dev|prod)$/, 'dev')
.option('-a, --analyze', 'Analyze client bundle. If set, `env` will be set to `prod`.')
.parse(process.argv);

if (cli.args[0] === 'build' || cli.analyze) {
if (cli.args[0] === 'build') {
cli.env = 'prod';
}

Expand Down Expand Up @@ -56,8 +55,7 @@ gulp.task('build', ['scripts.viewer', 'scripts.node']);
gulp.task('scripts.viewer', ['scripts.node', 'clean.scripts.viewer'], () => {
const webpack = require('webpack');
const config = require('./webpack.config')({
env: cli.env,
analyze: cli.analyze
env: cli.env
});

return new Promise((resolve, reject) => {
Expand Down
78 changes: 78 additions & 0 deletions packages/reporter-treemap/package.json
@@ -0,0 +1,78 @@
{
"name": "@webpack-bundle-analyzer/reporter-treemap",
"version": "3.0.0-alpha.0",
"description": "Reporter for webpack-bundle-analyzer that represents bundle content as convenient interactive zoomable treemap",
"author": "Yury Grunin <grunin.ya@ya.ru>",
"contributors": [
"Yury Grunin <grunin.ya@ya.ru>",
"Vesa Laakso <laakso.vesa@gmail.com> (http://vesalaakso.com)"
],
"license": "MIT",
"homepage": "https://github.com/webpack-bundle-analyzer/reporter-treemap",
"changelog": "https://github.com/webpack-bundle-analyzer/reporter-treemap/blob/master/CHANGELOG.md",
"bugs": {
"url": "https://github.com/webpack-bundle-analyzer/reporter-treemap/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/webpack-bundle-analyzer/reporter-treemap.git"
},
"main": "lib/index.js",
"engines": {
"node": ">= 4"
},
"scripts": {
"start": "gulp watch",
"build": "gulp build",
"npm-publish": "npm run build && npm publish"
},
"files": [
"lib",
"reporter/public",
"reporter/views",
"src"
],
"dependencies": {
"chalk": "^1.1.3",
"ejs": "^2.5.6",
"express": "^4.15.2",
"mkdirp": "^0.5.1",
"opener": "^1.4.3",
"ws": "^2.3.1"
},
"devDependencies": {
"babel-core": "6.24.1",
"babel-loader": "7.0.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"babel-plugin-transform-react-jsx": "6.24.1",
"babel-preset-env": "1.4.0",
"classnames": "2.2.5",
"commander": "2.9.0",
"css-loader": "0.28.1",
"del": "2.2.2",
"exports-loader": "0.6.4",
"filesize": "3.5.9",
"gulp": "3.9.1",
"gulp-babel": "6.1.2",
"gulp-plumber": "1.1.0",
"gulp-util": "3.0.8",
"gulp-watch": "4.3.11",
"preact": "8.1.0",
"stream-combiner2": "1.1.1",
"style-loader": "0.17.0",
"webpack": "2.5.1"
},
"keywords": [
"webpack",
"bundle",
"analyzer",
"modules",
"size",
"interactive",
"chart",
"treemap",
"zoomable",
"zoom"
]
}
@@ -1,5 +1,5 @@
{
"extends": "../../.eslintrc.json",
"extends": "../../../../.eslintrc.json",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions packages/reporter-treemap/src/index.js
@@ -0,0 +1,19 @@
const viewer = require('./viewer');

module.exports = {
generateReport,
createReporter
};

function generateReport(stats, opts) {
return viewer.generateReport(stats, opts);
}

function createReporter(initialChartData, opts) {
const server = viewer.startServer(initialChartData, opts);
return server.then(({ updateChartData }) => ({
updateData: newData => {
updateChartData(newData);
}
}));
}
6 changes: 2 additions & 4 deletions src/viewer.js → packages/reporter-treemap/src/viewer.js
Expand Up @@ -13,9 +13,7 @@ const reporterRoot = path.resolve(__dirname, '..', 'reporter');

module.exports = {
startServer,
generateReport,
// deprecated
start: startServer
generateReport
};

async function startServer(chartData, opts) {
Expand Down Expand Up @@ -56,7 +54,7 @@ async function startServer(chartData, opts) {
server.listen(port, host, () => {
resolve();

const url = `http://${host}:${server.address().port}`;
const url = `http://${host}:${port}`;

logger.info(
`${bold('Webpack Bundle Analyzer')} is started at ${bold(url)}\n` +
Expand Down
@@ -1,10 +1,8 @@
const webpack = require('webpack');
const BundleAnalyzePlugin = require('./lib/BundleAnalyzerPlugin');

module.exports = opts => {
opts = Object.assign({
env: 'dev',
analyze: false
env: 'dev'
}, opts);

return {
Expand Down Expand Up @@ -73,14 +71,6 @@ module.exports = opts => {
}

if (opts.env === 'prod') {
if (opts.analyze) {
plugins.push(
new BundleAnalyzePlugin({
generateStatsFile: true
})
);
}

plugins.push(
new webpack.DefinePlugin({
'process.env': {
Expand Down

0 comments on commit ad1304f

Please sign in to comment.