Skip to content

Commit c151062

Browse files
author
parkerziegler
committed
Simplify contribution process; integrate inspectpack fixtures.
1 parent ab047f9 commit c151062

29 files changed

+229
-12
lines changed

.eslintrc

-6
This file was deleted.

.eslintrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "formidable/configurations/es6-node",
3+
"rules": {
4+
"func-style": "off",
5+
"arrow-parens": ["error", "as-needed"]
6+
}
7+
}

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# dependencies
2-
node_modules
2+
/node_modules/
33

44
# misc
55
.DS_Store
66
npm-debug.log*
77
.nyc_output
88
.coverage
9-
.lankrc*
109
yarn-error.log
1110
package-lock.json
11+
dist-*
12+
.vscode

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ Webpack Dashboard works in Terminal, iTerm 2, and Hyper. For mouse events, like
9494

9595
*Note: you can also just pass a function in as an argument, which then becomes the handler, i.e. `new DashboardPlugin(dashboard.setData)`*
9696

97+
### Local Development
98+
99+
We've standardized our local development process for `webpack-dashboard` on using `yarn`. We recommend using `yarn 1.10.x+`, as these versions include the `integrity` checksum. The checksum helps to verify the integrity of an installed package before its code is executed. 🚀
100+
101+
To run this repo locally against our provided examples, take the usual steps.
102+
103+
```sh
104+
yarn
105+
yarn dev
106+
```
107+
108+
We re-use a small handful of the fixtures from [`inspectpack`](https://github.com/FormidableLabs/inspectpack) so that you can work locally on the dashboard while simulating common `node_modules` dependency issues you might face in the wild. These live in `/examples`.
109+
110+
To change the example you're working against, simply alter the `EXAMPLE` env variable in the `dev` script in `package.json` to match the scenario you want to run in `/examples`. For example, if you want to run the `tree-shaking` example, change the `dev` script from this:
111+
112+
```sh
113+
cross-env EXAMPLE=duplicates-esm node bin/webpack-dashboard.js -- webpack-cli --config examples/config/webpack.config.js --watch
114+
```
115+
116+
to this:
117+
118+
```sh
119+
cross-env EXAMPLE=tree-shaking node bin/webpack-dashboard.js -- webpack-cli --config examples/config/webpack.config.js --watch
120+
```
121+
122+
Then just run `yarn dev` to get up and running. PRs are very much appreciated!
123+
97124
#### Credits
98125

99126
Module output deeply inspired by: [https://github.com/robertknight/webpack-bundle-size-analyzer](https://github.com/robertknight/webpack-bundle-size-analyzer)

bin/webpack-dashboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const program = new commander.Command("webpack-dashboard");
1313
const pkg = require("../package.json");
1414

1515
// Wrap up side effects in a script.
16-
const main = module.exports = opts => { // eslint-disable-line max-statements
16+
const main = module.exports = opts => { // eslint-disable-line max-statements, complexity
1717
opts = opts || {};
1818
const argv = typeof opts.argv === "undefined" ? process.argv : opts.argv;
1919

examples/.eslintrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parserOptions": {
3+
"sourceType": "module"
4+
}
5+
}

examples/config/webpack.config.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { resolve } = require("path");
2+
const { StatsWriterPlugin } = require("webpack-stats-plugin");
3+
const { DuplicatesPlugin } = require("inspectpack/plugin");
4+
const Dashboard = require("../../plugin");
5+
6+
// Specify the directory of the example we're working with
7+
const cwd = `${process.cwd()}/examples/${process.env.EXAMPLE}`;
8+
if (!process.env.EXAMPLE) {
9+
throw new Error("EXAMPLE is required");
10+
}
11+
12+
module.exports = {
13+
mode: "development",
14+
devtool: false,
15+
context: resolve(cwd),
16+
entry: {
17+
bundle: "./src/index.js"
18+
},
19+
output: {
20+
path: resolve(cwd, "dist-development-4"),
21+
pathinfo: true,
22+
filename: "[name].js"
23+
},
24+
plugins: [
25+
new StatsWriterPlugin({
26+
fields: ["assets", "modules"]
27+
}),
28+
new DuplicatesPlugin({
29+
verbose: true,
30+
emitErrors: false
31+
}),
32+
new Dashboard()
33+
]
34+
};

examples/duplicates-esm/node_modules/foo/index.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/duplicates-esm/node_modules/foo/package.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/duplicates-esm/node_modules/uses-foo/index.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/duplicates-esm/node_modules/uses-foo/node_modules/foo/index.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/duplicates-esm/node_modules/uses-foo/node_modules/foo/package.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/duplicates-esm/node_modules/uses-foo/package.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/duplicates-esm/package.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "duplicates-esm",
3+
"version": "1.2.3",
4+
"description": "DUMMY APP",
5+
"main": "src/index.js",
6+
"dependencies": {
7+
"foo": "^1.0.0",
8+
"uses-foo": "^1.0.9"
9+
}
10+
}

examples/duplicates-esm/src/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable no-console*/
2+
import { foo } from "foo";
3+
import { usesFoo } from "uses-foo";
4+
5+
console.log("foo", foo());
6+
console.log("usesFoo", usesFoo());

examples/simple/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "simple",
3+
"version": "1.2.3",
4+
"description": "DUMMY APP",
5+
"main": "src/index.js"
6+
}

examples/simple/src/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
/* eslint-disable no-console*/
3+
4+
const hello = () => "hello world";
5+
6+
console.log(hello());

examples/tree-shaking/node_modules/foo/green.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/foo/index.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/foo/package.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/uses-foo/index.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/uses-foo/node_modules/foo/green.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/uses-foo/node_modules/foo/index.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/uses-foo/node_modules/foo/package.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/node_modules/uses-foo/package.json

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/tree-shaking/package.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "tree-shaking",
3+
"version": "1.2.3",
4+
"description": "DUMMY APP",
5+
"main": "src/index.js",
6+
"dependencies": {
7+
"foo": "^1.0.0",
8+
"uses-foo": "^1.0.9"
9+
}
10+
}

examples/tree-shaking/src/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable no-console*/
2+
3+
import { red } from "foo";
4+
import { usesRed } from "uses-foo";
5+
6+
console.log("red", red());
7+
console.log("usesRed", usesRed());

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"test-cov": "nyc mocha 'test/**/*.spec.js'",
1313
"lint": "eslint .",
1414
"check": "npm run lint && npm run test",
15-
"check-ci": "npm run lint && npm run test-cov"
15+
"check-ci": "npm run lint && npm run test-cov",
16+
"dev": "cross-env EXAMPLE=duplicates-esm node bin/webpack-dashboard.js -- webpack-cli --config examples/config/webpack.config.js --watch"
1617
},
1718
"repository": {
1819
"type": "git",
@@ -47,6 +48,7 @@
4748
"devDependencies": {
4849
"babel-eslint": "^8.2.3",
4950
"chai": "^4.1.2",
51+
"cross-env": "^5.2.0",
5052
"eslint": "^4.19.1",
5153
"eslint-config-formidable": "^4.0.0",
5254
"eslint-plugin-filenames": "^1.1.0",
@@ -57,6 +59,7 @@
5759
"sinon": "^5.0.7",
5860
"sinon-chai": "^3.0.0",
5961
"webpack": "^4.8.3",
60-
"webpack-cli": "^2.1.3"
62+
"webpack-cli": "^2.1.3",
63+
"webpack-stats-plugin": "^0.2.1"
6164
}
6265
}

yarn.lock

+14-1
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
19061906
safe-buffer "^5.0.1"
19071907
sha.js "^2.4.8"
19081908

1909+
cross-env@^5.2.0:
1910+
version "5.2.0"
1911+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
1912+
integrity sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg==
1913+
dependencies:
1914+
cross-spawn "^6.0.5"
1915+
is-windows "^1.0.0"
1916+
19091917
cross-spawn@^4:
19101918
version "4.0.2"
19111919
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41"
@@ -3564,7 +3572,7 @@ is-utf8@^0.2.0:
35643572
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
35653573
integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=
35663574

3567-
is-windows@^1.0.1, is-windows@^1.0.2:
3575+
is-windows@^1.0.0, is-windows@^1.0.1, is-windows@^1.0.2:
35683576
version "1.0.2"
35693577
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
35703578
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
@@ -6422,6 +6430,11 @@ webpack-sources@^1.0.1, webpack-sources@^1.1.0:
64226430
source-list-map "^2.0.0"
64236431
source-map "~0.6.1"
64246432

6433+
webpack-stats-plugin@^0.2.1:
6434+
version "0.2.1"
6435+
resolved "https://registry.yarnpkg.com/webpack-stats-plugin/-/webpack-stats-plugin-0.2.1.tgz#1f5bac13fc25d62cbb5fd0ff646757dc802b8595"
6436+
integrity sha512-OYMZLpZrK/qLA79NE4kC4DCt85h/5ipvWJcsefKe9MMw0qU4/ck/IJg+4OmWA+5EfrZZpHXDq92IptfYDWVfkw==
6437+
64256438
webpack@^4.8.3:
64266439
version "4.8.3"
64276440
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.8.3.tgz#957c8e80000f9e5cc03d775e78b472d8954f4eeb"

0 commit comments

Comments
 (0)