Skip to content

Commit 912aa8c

Browse files
committed
Drop gzip-size dependency
1 parent 0dcfb85 commit 912aa8c

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"acorn-walk": "^8.0.0",
3838
"chalk": "^4.1.0",
3939
"commander": "^6.2.0",
40-
"gzip-size": "^6.0.0",
4140
"lodash": "^4.17.20",
4241
"opener": "^1.5.2",
4342
"sirv": "^1.0.7",

src/analyzer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const fs = require('fs');
22
const path = require('path');
33

44
const _ = require('lodash');
5-
const gzipSize = require('gzip-size');
65

76
const Logger = require('./Logger');
87
const Folder = require('./tree/Folder').default;
98
const {parseBundle} = require('./parseUtils');
109
const {createAssetsFilter} = require('./utils');
10+
const {gzipSize} = require('./sizeUtils');
1111

1212
const FILENAME_QUERY_REGEXP = /\?.*$/u;
1313
const FILENAME_EXTENSIONS = /\.(js|mjs)$/iu;
@@ -102,7 +102,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
102102

103103
if (assetSources) {
104104
asset.parsedSize = Buffer.byteLength(assetSources.src);
105-
asset.gzipSize = gzipSize.sync(assetSources.src);
105+
asset.gzipSize = gzipSize(assetSources.src);
106106
}
107107

108108
// Picking modules from current bundle script

src/sizeUtils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const zlib = require('zlib');
2+
3+
export function gzipSize(input) {
4+
return zlib.gzipSync(input, {level: 9}).length;
5+
}

src/tree/Folder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import gzipSize from 'gzip-size';
2+
import {gzipSize} from '../sizeUtils';
33

44
import Module from './Module';
55
import BaseFolder from './BaseFolder';
@@ -14,7 +14,7 @@ export default class Folder extends BaseFolder {
1414

1515
get gzipSize() {
1616
if (!_.has(this, '_gzipSize')) {
17-
this._gzipSize = this.src ? gzipSize.sync(this.src) : 0;
17+
this._gzipSize = this.src ? gzipSize(this.src) : 0;
1818
}
1919

2020
return this._gzipSize;

src/tree/Module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import gzipSize from 'gzip-size';
2+
import {gzipSize} from '../sizeUtils';
33

44
import Node from './Node';
55

@@ -33,7 +33,7 @@ export default class Module extends Node {
3333

3434
get gzipSize() {
3535
if (!_.has(this, '_gzipSize')) {
36-
this._gzipSize = this.src ? gzipSize.sync(this.src) : undefined;
36+
this._gzipSize = this.src ? gzipSize(this.src) : undefined;
3737
}
3838

3939
return this._gzipSize;

0 commit comments

Comments
 (0)