From f0b37aaf45620be1469847bf7639e2beb8fc81f4 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Fri, 27 Dec 2019 08:00:16 +0000 Subject: [PATCH] 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 --- lib/filter.js | 13 +++++-------- package.json | 3 +-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/filter.js b/lib/filter.js index 5f4f63c..9ea979a 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -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)) diff --git a/package.json b/package.json index bae236a..1b4ea6e 100644 --- a/package.json +++ b/package.json @@ -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"