Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ coverage
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Dependency directories
node_modules/
Expand All @@ -42,9 +40,6 @@ jspm_packages/
# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ Spits out some stats about webpack compilation process to a file.
npm install --save-dev webpack-bundle-tracker
```

```bash
yarn add --dev webpack-bundle-tracker
```

<br>

## Usage
Expand Down
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class BundleTrackerPlugin {

// Set output directories
this.outputChunkDir = path.resolve(get(compiler.options, 'output.path', process.cwd()));
// @ts-ignore: TS2345 this.options.filename can't be undefined here because we set a default value above
this.outputTrackerFile = path.resolve(this.options.filename);
this.outputTrackerDir = path.dirname(this.outputTrackerFile);

Expand All @@ -84,6 +85,8 @@ class BundleTrackerPlugin {
* @param {string} content
*/
_computeIntegrity(content) {
// @ts-ignore: TS2532 this.options.integrityHashes can't be undefined here because
// we set a default value on _setParamsFromCompiler
return this.options.integrityHashes
.map(algorithm => {
const hash = crypto
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,50 @@
"scripts": {
"pretty": "prettier --loglevel warn --write lib/*.js tests/*.js",
"pretty-lint": "prettier --check lib/*.js tests/*.js",
"pretest": "yarn pretty-lint",
"pretest": "npm run pretty-lint",
"test": "jest --runInBand --env node",
"test-debug": "node --inspect-brk=0.0.0.0 node_modules/jest/bin/jest --runInBand --env node",
"posttest": "tsc",
"test-watch": "jest --runInBand --env node --watchAll",
"travis": "yarn pretest && jest --runInBand --coverage --env node && codecov && yarn posttest"
"travis": "npm pretest && jest --runInBand --coverage --env node && npm posttest"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was codecov not working here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, we should use coveralls instead due to recent security incidents.

},
"jest": {
"setupFilesAfterEnv": [
"jest-extended"
]
},
"dependencies": {
"@types/lodash.foreach": "^4.4.6",
"@types/lodash.foreach": "^4.5.6",
"@types/lodash.get": "^4.4.6",
"lodash.assign": "^4.2.0",
"lodash.defaults": "^4.2.0",
"lodash.foreach": "^4.2.0",
"lodash.foreach": "^4.5.0",
"lodash.get": "^4.4.2",
"strip-ansi": "^6.0.0"
},
"devDependencies": {
"@types/lodash.assign": "^4.2.6",
"@types/lodash.defaults": "^4.2.6",
"@types/mkdirp": "^1.0.0",
"@types/node": "^13.9.1",
"@types/webpack": "^4.41.7",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"codecov": "^3.6.5",
"commitizen": "^4.0.3",
"css-loader": "^3.4.2",
"cz-conventional-changelog": "3.1.0",
"@types/mkdirp": "^1.0.1",
"@types/node": "^13.13.52",
"@types/webpack": "^4.41.28",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"commitizen": "^4.2.4",
"compression-webpack-plugin": "^6.1.1",
"css-loader": "^5.2.4",
"cz-conventional-changelog": "3.3.0",
"eslint": "^6.8.0",
"file-loader": "^5.1.0",
"jest": "^25.1.0",
"jest": "^25.5.4",
"jest-extended": "^0.11.5",
"mini-css-extract-plugin": "^0.9.0",
"mini-css-extract-plugin": "^0.12.0",
"prettier": "^1.19.1",
"standard-version": "^7.1.0",
"style-loader": "^1.1.3",
"standard-version": "^9.3.0",
"style-loader": "^1.3.0",
"tslint": "^6.1.0",
"typescript": "^3.8.3",
"webpack": "^4.42.0"
"typescript": "^3.9.9",
"webpack": "^4.46.0"
},
"config": {
"commitizen": {
Expand Down
79 changes: 15 additions & 64 deletions tests/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('BundleTrackerPlugin bases tests', () => {
plugins: [
new BundleTrackerPlugin({
path: OUTPUT_DIR,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
}),
],
},
Expand Down Expand Up @@ -76,6 +77,7 @@ describe('BundleTrackerPlugin bases tests', () => {
plugins: [
new BundleTrackerPlugin({
path: OUTPUT_DIR,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
logTime: true,
}),
],
Expand Down Expand Up @@ -108,6 +110,7 @@ describe('BundleTrackerPlugin bases tests', () => {
plugins: [
new BundleTrackerPlugin({
path: OUTPUT_DIR,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
publicPath: 'https://test.org/statics/',
}),
],
Expand Down Expand Up @@ -152,7 +155,7 @@ describe('BundleTrackerPlugin bases tests', () => {
plugins: [
new BundleTrackerPlugin({
path: OUTPUT_DIR,
filename: filename,
filename: path.join(OUTPUT_DIR, filename),
}),
],
},
Expand Down Expand Up @@ -194,7 +197,7 @@ describe('BundleTrackerPlugin bases tests', () => {
plugins: [
new BundleTrackerPlugin({
path: OUTPUT_DIR,
filename: filename,
filename: path.join(OUTPUT_DIR, filename),
}),
],
},
Expand Down Expand Up @@ -237,6 +240,7 @@ describe('BundleTrackerPlugin bases tests', () => {
new BundleTrackerPlugin({
path: OUTPUT_DIR,
publicPath: 'https://test.org/statics/',
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
}),
],
},
Expand Down Expand Up @@ -271,6 +275,7 @@ describe('BundleTrackerPlugin bases tests', () => {
new BundleTrackerPlugin({
path: OUTPUT_DIR,
relativePath: true,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
}),
],
},
Expand Down Expand Up @@ -339,21 +344,17 @@ describe('BundleTrackerPlugin bases tests', () => {
path: OUTPUT_DIR,
relativePath: true,
includeParents: true,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
}),
],
},
{
status: 'done',
chunks: {
app1: ['js/vendors.js', 'js/commons.js', 'js/app1.js'],
app2: ['js/vendors.js', 'js/commons.js', 'js/app2.js'],
app1: ['js/commons.js', 'js/app1.js'],
app2: ['js/commons.js', 'js/app2.js'],
},
assets: {
'js/2.js': {
name: 'js/2.js',
path: 'js/2.js',
publicPath: 'http://localhost:3000/assets/js/2.js',
},
'js/app1.js': {
name: 'js/app1.js',
path: 'js/app1.js',
Expand All @@ -369,11 +370,6 @@ describe('BundleTrackerPlugin bases tests', () => {
path: 'js/commons.js',
publicPath: 'http://localhost:3000/assets/js/commons.js',
},
'js/vendors.js': {
name: 'js/vendors.js',
path: 'js/vendors.js',
publicPath: 'http://localhost:3000/assets/js/vendors.js',
},
},
},
'webpack-stats.json',
Expand Down Expand Up @@ -433,14 +429,15 @@ describe('BundleTrackerPlugin bases tests', () => {
relativePath: true,
includeParents: true,
integrity: true,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
}),
],
},
{
status: 'done',
chunks: {
app1: ['js/vendors.js', 'js/commons.js', 'js/app1.js'],
appWithAssets: ['js/vendors.js', 'js/commons.js', 'styles.css', 'js/appWithAssets.js'],
app1: ['js/commons.js', 'js/app1.js'],
appWithAssets: ['js/commons.js', 'styles.css', 'js/appWithAssets.js'],
},
publicPath: 'http://localhost:3000/assets/',
assets: {
Expand All @@ -450,18 +447,6 @@ describe('BundleTrackerPlugin bases tests', () => {
integrity: expect.stringMatching(/^^sha256-[\w+=/]+ sha384-[\w+=/]+ sha512-[\w+=/]+$/),
publicPath: 'http://localhost:3000/assets/js/commons.js',
},
'js/vendors.js': {
name: 'js/vendors.js',
path: 'js/vendors.js',
integrity: expect.stringMatching(/^^sha256-[\w+=/]+ sha384-[\w+=/]+ sha512-[\w+=/]+$/),
publicPath: 'http://localhost:3000/assets/js/vendors.js',
},
'js/2.js': {
name: 'js/2.js',
path: 'js/2.js',
integrity: expect.stringMatching(/^^sha256-[\w+=/]+ sha384-[\w+=/]+ sha512-[\w+=/]+$/),
publicPath: 'http://localhost:3000/assets/js/2.js',
},
'js/app1.js': {
name: 'js/app1.js',
path: 'js/app1.js',
Expand Down Expand Up @@ -557,19 +542,15 @@ describe('BundleTrackerPlugin bases tests', () => {
path: OUTPUT_DIR,
relativePath: true,
includeParents: true,
filename: path.join(OUTPUT_DIR, 'webpack-stats.json'),
}),
],
},
{
status: 'done',
chunks: {
app1: [
expect.stringMatching(/^js\/vendors.js$/),
expect.stringMatching(/^js\/commons.js$/),
expect.stringMatching(/^js\/app1.js$/),
],
app1: [expect.stringMatching(/^js\/commons.js$/), expect.stringMatching(/^js\/app1.js$/)],
appWithAssets: [
expect.stringMatching(/^js\/vendors.js$/),
expect.stringMatching(/^js\/commons.js$/),
expect.stringMatching(/^css\/appWithAssets.css$/),
expect.stringMatching(/^js\/appWithAssets.js$/),
Expand All @@ -581,16 +562,6 @@ describe('BundleTrackerPlugin bases tests', () => {
path: 'js/commons.js',
publicPath: 'http://localhost:3000/assets/js/commons.js',
},
'js/vendors.js': {
name: 'js/vendors.js',
path: 'js/vendors.js',
publicPath: 'http://localhost:3000/assets/js/vendors.js',
},
'js/2.js': {
name: 'js/2.js',
path: 'js/2.js',
publicPath: 'http://localhost:3000/assets/js/2.js',
},
'js/app1.js': {
name: 'js/app1.js',
path: 'js/app1.js',
Expand All @@ -611,16 +582,6 @@ describe('BundleTrackerPlugin bases tests', () => {
path: 'js/commons.js.gz',
publicPath: 'http://localhost:3000/assets/js/commons.js.gz',
},
'js/vendors.js.gz': {
name: 'js/vendors.js.gz',
path: 'js/vendors.js.gz',
publicPath: 'http://localhost:3000/assets/js/vendors.js.gz',
},
'js/2.js.gz': {
name: 'js/2.js.gz',
path: 'js/2.js.gz',
publicPath: 'http://localhost:3000/assets/js/2.js.gz',
},
'js/app1.js.gz': {
name: 'js/app1.js.gz',
path: 'js/app1.js.gz',
Expand All @@ -641,21 +602,11 @@ describe('BundleTrackerPlugin bases tests', () => {
path: 'js/commons.js.br',
publicPath: 'http://localhost:3000/assets/js/commons.js.br',
},
'js/2.js.br': {
name: 'js/2.js.br',
path: 'js/2.js.br',
publicPath: 'http://localhost:3000/assets/js/2.js.br',
},
'css/appWithAssets.css.br': {
name: 'css/appWithAssets.css.br',
path: 'css/appWithAssets.css.br',
publicPath: 'http://localhost:3000/assets/css/appWithAssets.css.br',
},
'js/vendors.js.br': {
name: 'js/vendors.js.br',
path: 'js/vendors.js.br',
publicPath: 'http://localhost:3000/assets/js/vendors.js.br',
},
'js/app1.js.br': {
name: 'js/app1.js.br',
path: 'js/app1.js.br',
Expand Down
Loading