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

Better way to compress #10

Closed
sirenkovladd opened this issue Jan 9, 2024 · 7 comments
Closed

Better way to compress #10

sirenkovladd opened this issue Jan 9, 2024 · 7 comments
Labels

Comments

@sirenkovladd
Copy link
Contributor

import {minify} from '@putout/minify';
const js = `console.log(x + "g");`
const min = minify(js)
console.log(min)
❯ node tt.js
console.log(`${x}g`);

it seems that if you leave this line as an addition, the result will be smaller

console.log(`${x}g`);
console.log(x+'g');

is it not considered an option to either remove the conversion to template literals, or add a check of the original size?

@sirenkovladd
Copy link
Contributor Author

But for

const js = `throw new Error('The language "' + r.language + '" has no grammar.');`

it was done differently
I think this is a mistake
because actually it would be better to use template literals here

@coderaiser
Copy link
Contributor

We can add option to disable such transformation, about second case - it’s hard to implement, but PR’s a welcome

@coderaiser
Copy link
Contributor

coderaiser commented Jan 9, 2024

Just landed ability to disable apply-template-literals plugin 🎉 . Is it works for you?

@sirenkovladd
Copy link
Contributor Author

As I understood in these changes, only that you turn off this transformation, without additional checking which of the options will be better

but unfortunately, the problem indicated in the title is not solved

@coderaiser
Copy link
Contributor

There is no place I can add the check right now, but you can add a new rule to minify plugin which will check the size and apply transformation (instead of this one).

@coderaiser
Copy link
Contributor

Closed due to a long time of inactivity 🏝

@coderaiser
Copy link
Contributor

Also this can be implemented using @putout/minify API, you can always run with one set of options, and then use another one and check which is better for you.

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

No branches or pull requests

2 participants