diff --git a/packages/file/index.js b/packages/file/index.js index b6f0556f..2d54c9e8 100644 --- a/packages/file/index.js +++ b/packages/file/index.js @@ -1,10 +1,6 @@ import { createReadStream } from 'node:fs' import { stat } from 'node:fs/promises' import { constants, createBrotliCompress, createGzip } from 'node:zlib' -import { gte } from 'semver' -import { SizeLimitError } from 'size-limit' - -const BROTLI_NODE_VERSION = 'v11.7.0' async function sum(array, fn) { return (await Promise.all(array.map(fn))).reduce((all, i) => all + i, 0) @@ -51,9 +47,6 @@ export default [ let files = check.bundles || check.files if (check.brotli === true) { - if (!gte(process.version, BROTLI_NODE_VERSION)) { - throw new SizeLimitError('brotliUnsupported') - } check.size = await sum(files, async i => brotliSize(i)) } else if (check.gzip === false) { check.size = await sum(files, async i => (await stat(i)).size) diff --git a/packages/file/package.json b/packages/file/package.json index 67cc4a68..da8307ca 100644 --- a/packages/file/package.json +++ b/packages/file/package.json @@ -24,9 +24,6 @@ "peerDependencies": { "size-limit": "10.0.2" }, - "dependencies": { - "semver": "7.5.4" - }, "devDependencies": { "size-limit": "workspace:^" } diff --git a/packages/file/test/index.test.js b/packages/file/test/index.test.js index 3d24ebc1..ebc05d08 100644 --- a/packages/file/test/index.test.js +++ b/packages/file/test/index.test.js @@ -1,5 +1,4 @@ import { join } from 'node:path' -import { SizeLimitError } from 'size-limit' import { expect, it } from 'vitest' import filePkg from '../index.js' @@ -57,25 +56,6 @@ it('calculates file size with brotli by true value and node >= v11.7.0', async ( expect(config.checks[0].size).toBe(17) }) -it('calculates file size with brotli by true value and node < v11.7.0', async () => { - Object.defineProperty(process, 'version', { - value: 'v11.6.0' - }) - - let config = { - checks: [{ brotli: true, files: [fixture('b.txt')] }] - } - - let err - try { - await file.step60(config, config.checks[0]) - } catch (e) { - err = e - } - - expect(err).toEqual(new SizeLimitError('brotliUnsupported')) -}) - it('uses webpack bundle if available', async () => { let config = { checks: [{ bundles: [fixture('a.txt')], files: [fixture('b.txt')] }] diff --git a/packages/size-limit/size-limit-error.js b/packages/size-limit/size-limit-error.js index 9d21bca1..17e0408b 100644 --- a/packages/size-limit/size-limit-error.js +++ b/packages/size-limit/size-limit-error.js @@ -10,8 +10,6 @@ const MESSAGES = { argWithoutPlugins: (arg, mod1, mod2) => `Argument *--${arg}* needs *@size-limit/${mod1}* ` + `or *@size-limit/${mod2}* plugin`, - brotliUnsupported: () => - 'Update your Node.js to version >= v11.7.0 to use Brotli', bundleDirNotEmpty: dir => `The directory *${dir}* is not empty. ` + 'Pass *--clean-dir* if you want to remove it', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6830ff13..89e1931a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -132,10 +132,6 @@ importers: version: link:../size-limit packages/file: - dependencies: - semver: - specifier: 7.5.4 - version: 7.5.4 devDependencies: size-limit: specifier: workspace:^