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

feat(codegen): prefer backquotes over double / single quotes #8839

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Feb 2, 2025

When thinking about why #8443 made the gzip size increased, I thought it maybe because the backquotes appear more than before the PR. So I changed the codegen to prefer backquotes than double/single quotes. It seems this separate change have a positive effect with some projects.
My guess is that in most projects, back quotes does not appear in string literals than double quotes and single quotes.

The gzipped size slightly increases for bundle.min.js, victory.js, antd.js, but those will be decreased by #8443 except for bundle.min.js.

@github-actions github-actions bot added A-codegen Area - Code Generation C-enhancement Category - New feature or request labels Feb 2, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sapphi-red sapphi-red marked this pull request as ready for review February 2, 2025 10:18
Copy link

codspeed-hq bot commented Feb 2, 2025

CodSpeed Performance Report

Merging #8839 will not alter performance

Comparing 02-02-feat_codegen_prefer_backquotes_over_double___single_quotes (b4ee617) with main (84b62c7)

Summary

✅ 33 untouched benchmarks

@sapphi-red
Copy link
Member Author

sapphi-red commented Feb 2, 2025

It seems I need to add allow_backtick: false to more places for TypeScript codegen. done

@sapphi-red sapphi-red marked this pull request as draft February 2, 2025 10:22
@sapphi-red sapphi-red force-pushed the 02-02-feat_codegen_prefer_backquotes_over_double___single_quotes branch 2 times, most recently from df82694 to 3cf8a9c Compare February 3, 2025 06:24
@sapphi-red sapphi-red marked this pull request as ready for review February 3, 2025 06:28
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Feb 3, 2025
Copy link

graphite-app bot commented Feb 3, 2025

Merge activity

When thinking about why #8443 made the gzip size increased, I thought it maybe because the backquotes appear more than before the PR. So I changed the codegen to prefer backquotes than double/single quotes. It seems this separate change have a positive effect with some projects.
My guess is that in most projects, back quotes does not appear in string literals than double quotes and single quotes.

The gzipped size slightly increases for `bundle.min.js`, `victory.js`, `antd.js`, but those will be decreased by #8443 except for `bundle.min.js`.
@graphite-app graphite-app bot force-pushed the 02-02-feat_codegen_prefer_backquotes_over_double___single_quotes branch from 3cf8a9c to b4ee617 Compare February 3, 2025 07:21
graphite-app bot pushed a commit that referenced this pull request Feb 3, 2025
Compress `"".concat(a, "b", c)` into `` `${a}b${c}` ``.

~~I'm not sure if this should be merged. It works for antd but it doesn't for typescript.~~ Now with #8839, it works well for typescript as well.

**References**
- [Spec of `String::concat`](https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.concat)
- [Spec of template literal](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-template-literals-runtime-semantics-evaluation)
@graphite-app graphite-app bot merged commit b4ee617 into main Feb 3, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 02-02-feat_codegen_prefer_backquotes_over_double___single_quotes branch February 3, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-codegen Area - Code Generation C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant