Skip to content

Commit

Permalink
Remove old Node.js version check
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Nov 11, 2023
1 parent 27727eb commit f24ae82
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 36 deletions.
7 changes: 0 additions & 7 deletions packages/file/index.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions packages/file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
"peerDependencies": {
"size-limit": "10.0.2"
},
"dependencies": {
"semver": "7.5.4"
},
"devDependencies": {
"size-limit": "workspace:^"
}
Expand Down
20 changes: 0 additions & 20 deletions packages/file/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { join } from 'node:path'
import { SizeLimitError } from 'size-limit'
import { expect, it } from 'vitest'

import filePkg from '../index.js'
Expand Down Expand Up @@ -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')] }]
Expand Down
2 changes: 0 additions & 2 deletions packages/size-limit/size-limit-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 0 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f24ae82

Please sign in to comment.