Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to minification-benchmarks #28

Open
sirenkovladd opened this issue Sep 26, 2024 · 12 comments
Open

Add to minification-benchmarks #28

sirenkovladd opened this issue Sep 26, 2024 · 12 comments

Comments

@sirenkovladd
Copy link
Contributor

Try running minification for these libraries and add yourself to the list

https://github.com/privatenumber/minification-benchmarks

@coderaiser
Copy link
Contributor

I don’t mind if you do it, and share link here.

@sirenkovladd
Copy link
Contributor Author

error with the first lib
https://replit.com/@sirenkovladd/putoutminify#result.log

@coderaiser
Copy link
Contributor

Could you please provide minimal example of code, about 10 lines that errored?

@sirenkovladd
Copy link
Contributor Author

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:

  • that incorrectly replaced arguments
  • args can be minified

@sirenkovladd
Copy link
Contributor Author

I would like to note regarding your previous comment that the code runs successfully before minification

@coderaiser
Copy link
Contributor

coderaiser commented Sep 27, 2024

what do you mean by incorrectly replaced arguments?

coderaiser added a commit to coderaiser/putout that referenced this issue Sep 27, 2024
@coderaiser
Copy link
Contributor

Just fixed 🎉. Is it works for you?

@sirenkovladd
Copy link
Contributor Author

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

@sirenkovladd
Copy link
Contributor Author

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

@coderaiser
Copy link
Contributor

coderaiser commented Sep 29, 2024

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:

@coderaiser
Copy link
Contributor

SyntaxError: Function statements require a function name

Just fixed 🎉. Please update @putout/minify, is it works for you?

kodiakhq bot pushed a commit to relaycorp/eslint-config that referenced this issue Oct 7, 2024
Bumps [putout](https://github.com/coderaiser/putout) from 36.5.1 to 36.9.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/coderaiser/putout/releases">putout's releases</a>.</em></p>
<blockquote>
<h2>putout v36.9.0</h2>
<h2>🐞 fix</h2>
<ul>
<li>d24950965 <code>@​putout/plugin-package-json</code>: remove-exports-with-missing-files: indent: 4 -&gt; 2</li>
<li>037f06789 <code>@​putout/plugin-nodejs</code>: remove-illigal-strict-mode -&gt; remove-illegal-strict-mode</li>
</ul>
<h2>🔥 feature</h2>
<ul>
<li>9340f32a9 <code>@​putout/plugin-remove-useless-push</code>: add</li>
<li>8883e2e8f <code>@​putout/plugin-package-json</code>: remove-exports-with-missing-files: add</li>
<li>ca4ecd296 <code>@​putout/plugin-putout</code>: add-path-arg-to-## 🐞 fix
exclude empty body</li>
<li>587da10e6 <code>@​putout/plugin-putout</code>: add-track-file: one arg</li>
<li>cf3f4c49a <code>@​putout/plugin-convert-arguments-to-rest</code>: exclude &quot;strict mode&quot;</li>
</ul>
<h2>putout v36.8.0</h2>
<h2>🔥 feature</h2>
<ul>
<li>2242decc7 putout: <code>@​putout/plugin-nodejs</code> v12.0.0</li>
<li>425cef48a <code>@​putout/plugin-nodejs</code>: drop support of 🐊 &lt; 36</li>
<li>dc160ba2d <code>@​putout/plugin-putout</code>: add-path-arg-to-## 🐞 fix
body</li>
<li>a24b23725 <code>@​putout/plugin-nodejs</code><code>putoutjs/minify#28</code></li>
<li>dd34149f4 putout: <code>@​putout/plugin-convert-arguments-to-rest</code> v3.0.0</li>
<li>e3f4f6908 <code>@​putout/operate</code>: getProperty: ObjectPattern support</li>
<li>6b454ed4f <code>@​putout/plugin-package-json</code>: apply-https-to-repository-url: improve check</li>
<li>9bc776976 <code>@​putout/plugin-convert-arguments-to-rest</code>: drop support of 🐊 &lt; 36</li>
<li>48beb1a07 <code>@​putout/plugin-convert-arguments-to-rest</code><code>putoutjs/minify#28</code></li>
</ul>
<h2>putout v36.7.0</h2>
<h2>🔥 feature</h2>
<ul>
<li>5d9d805b7 putout: <code>@​putout/plugin-package-json</code> v8.0.0</li>
<li>22b90580f <code>@​putout/plugin-package-json</code>: drop support of 🐊 &lt; 36</li>
<li>3c80fdddd <code>@​putout/operate</code>: getProperty: check that path is ObjectExpression</li>
<li>a27d72de2 <code>@​putout/plugin-package-json</code>: appy-https-to-repository-url</li>
</ul>
<h2>putout v36.6.2</h2>
<h2>🐞 fix</h2>
<ul>
<li>6c0207700 putout: rm unused exports</li>
</ul>
<h2>🔥 feature</h2>
<ul>
<li>559fcd1ed <code>@​putout/plugin-remove-useless-variables</code><code>coderaiser/minify#128</code></li>
</ul>
<h2>putout v36.6.1</h2>
<h2>🔥 feature</h2>
<ul>
<li>00f1be349 putout: <code>@​putout/plugin-madrun</code> v19.0.0</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/coderaiser/putout/commit/3a29a4dcfa23ffc9e9fa918af86fc69f0c0e3066"><code>3a29a4d</code></a> chore: putout: v36.9.0</li>
<li><a href="https://github.com/coderaiser/putout/commit/625d6e0baecbcb8fd7116d4b00eaf8c4cb44c296"><code>625d6e0</code></a> chore: <code>@​putout/plugin-package-json</code>: v8.2.2</li>
<li><a href="https://github.com/coderaiser/putout/commit/d24950965ec2c4e372709b896ae29d96505b5283"><code>d249509</code></a> fix: <code>@​putout/plugin-package-json</code>: remove-exports-with-missing-files: indent: ...</li>
<li><a href="https://github.com/coderaiser/putout/commit/a14892c59c9ad7ed7fa0ec98ec97d9b4597d25d4"><code>a14892c</code></a> chore: <code>@​putout/plugin-package-json</code>: v8.2.1</li>
<li><a href="https://github.com/coderaiser/putout/commit/9340f32a9aca0558f3ed1e6bf5cb60b5ba386322"><code>9340f32</code></a> feature: <code>@​putout/plugin-remove-useless-push</code>: add</li>
<li><a href="https://github.com/coderaiser/putout/commit/0b203f45cce0ab14ee6bf0870faaa887ec45b9b0"><code>0b203f4</code></a> chore: <code>@​putout/plugin-package-json</code>: v8.2.0</li>
<li><a href="https://github.com/coderaiser/putout/commit/8883e2e8f7f1f975d6e73cc5c7d88dcfdd452c59"><code>8883e2e</code></a> feature: <code>@​putout/plugin-package-json</code>: remove-exports-with-missing-files: add</li>
<li><a href="https://github.com/coderaiser/putout/commit/83e80e7ea6dbf6a37985ffc86c9eb47503b6d9ee"><code>83e80e7</code></a> chore: <code>@​putout/plugin-putout</code>: v21.4.0</li>
<li><a href="https://github.com/coderaiser/putout/commit/ca4ecd2967fb7ecbdf614cc7b56a811b723185da"><code>ca4ecd2</code></a> feature: <code>@​putout/plugin-putout</code>: add-path-arg-to-fix: exclude empty body</li>
<li><a href="https://github.com/coderaiser/putout/commit/d0ec03893f4765d5694d510f41298d2a1f943527"><code>d0ec038</code></a> chore: <code>@​putout/plugin-putout</code>: v21.3.0</li>
<li>Additional commits viewable in <a href="https://github.com/coderaiser/putout/compare/v36.5.1...v36.9.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=putout&package-manager=npm_and_yarn&previous-version=36.5.1&new-version=36.9.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants