Open sirenkovladd opened 2 months ago
I don’t mind if you do it, and share link here.
error with the first lib https://replit.com/@sirenkovladd/putoutminify#result.log
Could you please provide minimal example of code, about 10 lines that errored?
import {minify} from '@putout/minify';
async function main() {
const body = `(function() {
'use strict';
function createElement() {
for (let i in arguments) {
childArray[i] = arguments[i + 2];
}
}
})();`;
eval(body)
const result = minify(body);
console.log(result);
eval(result)
}
main();
(function(...args){'use strict';function a(){for(let i in args)childArray[i]=args[i+2]}})();
undefined:1
(function(...args){'use strict';function a(){for(let i in args)childArray[i]=args[i+2]}})();
^^^^^^^^^^^^
SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list
at main (file:///private/var/folders/36/nhtbdyy51gg2n2snnk7c7gnr0000gn/T/tmp.09BhuIycnU/index.mjs:15:8)
at file:///private/var/folders/36/nhtbdyy51gg2n2snnk7c7gnr0000gn/T/tmp.09BhuIycnU/index.mjs:18:1
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:475:24)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5)
Node.js v22.2.0
additional error:
args
can be minifiedI would like to note regarding your previous comment that the code runs successfully before minification
what do you mean by incorrectly replaced arguments
?
Just fixed 🎉. Is it works for you?
import {minify} from '@putout/minify';
async function main() {
// lodash
const body = `;(function() {}.call(this));`
eval(body)
const result = minify(body);
console.log(result);
eval(result)
}
main();
❯ node lodash.cjs
;function(){}.call(this);
undefined:1
;function(){}.call(this);
^^^^^^^^
SyntaxError: Function statements require a function name
at main (/private/var/folders/36/nhtbdyy51gg2n2snnk7c7gnr0000gn/T/tmp.09BhuIycnU/lodash.cjs:22:8)
Node.js v22.2.0
I can't minimize d3
, I waited more than 6 minutes but still didn't get the result
npm i d3
https://unpkg.com/browse/d3@7.9.0/dist/d3.js
import {minify} from '@putout/minify';
import { readFile } from 'node:fs/promises'
async function main() {
const body = await readFile('./node_modules/d3/dist/d3.js', 'utf8');
eval(body)
const start = new Date();
console.log(start);
const result = minify(body);
console.log(new Date());
console.log(new Date() - start);
eval(result)
}
main();
❯ node d3.mjs
2024-09-28T00:11:33.023Z
^C
I can't minimize d3, I waited more than 6 minutes but still didn't get the result
Let's try to figure out the case:
dev
path https://github.com/putoutjs/minify/blob/master/package.json#L14 to use @putout/minify
without building;SyntaxError: Function statements require a function name
Just fixed 🎉. Please update @putout/minify
, is it works for you?
Try running minification for these libraries and add yourself to the list
https://github.com/privatenumber/minification-benchmarks