Skip to content

Commit

Permalink
Fix breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlb committed May 13, 2021
1 parent 794b6fd commit 5b82c7a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 72 deletions.
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"commitizen": "^4.2.4",
"compression-webpack-plugin": "^7.1.2",
"compression-webpack-plugin": "^6.1.1",
"css-loader": "^3.6.0",
"cz-conventional-changelog": "3.3.0",
"eslint": "^6.8.0",
Expand Down
67 changes: 5 additions & 62 deletions tests/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,10 @@ describe('BundleTrackerPlugin bases tests', () => {
{
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 @@ -375,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 @@ -446,8 +436,8 @@ describe('BundleTrackerPlugin bases tests', () => {
{
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 @@ -457,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 @@ -571,13 +549,8 @@ describe('BundleTrackerPlugin bases tests', () => {
{
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 @@ -589,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 @@ -619,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 @@ -649,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

0 comments on commit 5b82c7a

Please sign in to comment.