chore: requires at least Node 10.18

BREAKING CHANGE: Drop Node 8 and iltorb
- utilize native brotli
- Drop string-to-buffer conversion
  * conversion was necessary for iltorb
This commit is contained in:
curbengh 2019-12-27 08:00:16 +00:00
parent 48868bfa7e
commit f0b37aaf45
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
2 changed files with 6 additions and 10 deletions

View File

@ -7,7 +7,7 @@ const Svgo = require('svgo')
const zlib = require('zlib')
const { promisify } = require('util')
const gzip = promisify(zlib.gzip)
const br = require('zlib').brotliCompress ? promisify(require('zlib').brotliCompress) : require('iltorb').compress
const br = promisify(zlib.brotliCompress)
const micromatch = require('micromatch')
const isMatch = (path = '', patterns = [], options = {}) => {
@ -151,10 +151,8 @@ function gzipFn () {
assetPath.on('end', async () => {
if (assetTxt.length) {
try {
// TODO: Drop Buffer
const input = Buffer.from(assetTxt, 'utf-8')
const result = await gzip(input, { level })
if (options.logger) verbose.call(this, input, result, path, 'gzip')
const result = await gzip(assetTxt, { level })
if (options.logger) verbose.call(this, assetTxt, result, path, 'gzip')
resolve(route.set(path + '.gz', result))
} catch (err) {
reject(new Error(err))
@ -188,9 +186,8 @@ function brotliFn () {
assetPath.on('end', async () => {
if (assetTxt.length) {
try {
const input = Buffer.from(assetTxt, 'utf-8')
const result = await br(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: level } })
if (options.logger) verbose.call(this, input, result, path, 'brotli')
const result = await br(assetTxt, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: level } })
if (options.logger) verbose.call(this, assetTxt, result, path, 'brotli')
resolve(route.set(path + '.br', result))
} catch (err) {
reject(new Error(err))

View File

@ -16,7 +16,7 @@
"test": "jest test/filter.test.js"
},
"engines": {
"node": ">= 8.6.0"
"node": ">= 10.18.0"
},
"author": "curben",
"license": "MIT",
@ -25,7 +25,6 @@
"dependencies": {
"clean-css": "^4.2.1",
"html-minifier": "^4.0.0",
"iltorb": "^2.4.2",
"micromatch": "^4.0.2",
"svgo": "^1.2.2",
"terser": "^4.0.0"