putoutjs / minify

Minify with help of 🐊Putout
MIT License
12 stars 3 forks source link

Cannot read properties of null (reading 'declarations') rule: 'for-of/for-each' #7

Closed sirenkovladd closed 10 months ago

sirenkovladd commented 10 months ago
import {minify} from '@putout/minify';
const js=`const l=[];l.forEach(function (o) {
  var c = o.sizer;
  g.forEach(function (v, w) {
    if (v && v.length > 1) {
      var t = c.appendChild(document.createElement("span"));
    } else m[w] = y;
  });
}),
  l.forEach(function (o) {
    for (
      var c = o.sizer;
      y < g.length;
      y++
    )
      g[y] = c.children[m++];
  });console.log('hello')`;
eval(js);
try{minify(js)}catch(e){console.log(e)}
❯ node tt.js
hello
TypeError: Cannot read properties of null (reading 'declarations')
    at e.push (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:800988)
    at Object.emit (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:820145)
    at Object.VariableDeclaration (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:775194)
    at e._call (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:845808)
    at e.call (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:845652)
    at e.visit2 [as visit] (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:846658)
    at TraversalContext.visitQueue (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:873210)
    at TraversalContext.visitSingle (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:872915)
    at TraversalContext.visit (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:873485)
    at traverseNode (file:///Users/vlad/programming/vanjs-org.github.io/new/node_modules/@putout/minify/bundle/minify.min.js:1:873777) {
  loc: { line: 9, column: 2 },
  rule: 'for-of/for-each'
}
sirenkovladd commented 10 months ago

This is part of the code that was generated automatically with esbuild accordingly, I will not be able to change it with the help of eval you can see that the syntax must be valid

coderaiser commented 10 months ago

Just fixed 🎉 , please re-install @putout/minify. Is it works for you?