express-minify icon indicating copy to clipboard operation
express-minify copied to clipboard

`express-minify` +`terser` ?

Open LSafer opened this issue 3 years ago • 0 comments

I got an overall idea about what is going on. I understood that terser the module to uglify modern JS. But, I tried to use it using the uglifyJsModule. It looks like it is not compatible with express-minify.

Code:

const _express_minify = require('express-minify');
const _terser = require('terser');
app.use(_express_minify({
    cache: false,
    jsMatch: /javascript|js/g,
    errorHandler: error => {
        console.error(error);
    },
    uglifyJsModule: _terser
}));

Output:

_http_outgoing.js:696
    throw new ERR_INVALID_ARG_TYPE('first argument',
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received undefined
    at write_ (_http_outgoing.js:696:11)
    at ServerResponse.write (_http_outgoing.js:661:15)
    at C:\Projects\openstore\node_modules\express-minify\index.js:151:23
    at MemoryCache.put (C:\Projects\openstore\node_modules\express-minify\cache.js:46:3)
    at C:\Projects\openstore\node_modules\express-minify\index.js:150:27
    at C:\Projects\openstore\node_modules\express-minify\minifier.js:173:5
    at Minifier._minifyJavaScript (C:\Projects\openstore\node_modules\express-minify\minifier.js:63:3)
    at Minifier._compileAndMinify (C:\Projects\openstore\node_modules\express-minify\minifier.js:155:15)
    at Minifier.compileAndMinify (C:\Projects\openstore\node_modules\express-minify\minifier.js:164:8)
    at C:\Projects\openstore\node_modules\express-minify\index.js:144:20 {
  code: 'ERR_INVALID_ARG_TYPE'
}

LSafer avatar Nov 18 '20 10:11 LSafer