Skip to content

Set ascii_only for swc emit#9243

Merged
mischnic merged 3 commits into
v2from
emit-ascii-only
Sep 27, 2023
Merged

Set ascii_only for swc emit#9243
mischnic merged 3 commits into
v2from
emit-ascii-only

Conversation

@mischnic

@mischnic mischnic commented Sep 13, 2023

Copy link
Copy Markdown
Member

Closes #8877

Don't replace unicode escape sequences with the corresponding unicode character, but leave that to the optimizer (which makes it possible to disable the replacement with a terserrc)

This was the case some time ago

Comment thread packages/core/integration-tests/test/javascript.js
swc_core::ecma::codegen::Config::default().with_target(swc_core::ecma::ast::EsVersion::Es5);
let config = swc_core::ecma::codegen::Config::default()
.with_target(swc_core::ecma::ast::EsVersion::Es5)
.with_ascii_only(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also affect pre-existing unicode characters? E.g. does it turn '🙂' into '\uD83D\uDE42'?

@mischnic mischnic Sep 14, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. So I think we shouldn't actually do this.

This leads to the question: if Chrome allows 🙂, then why does it not allow some other unicode that is probably equally valid? (Unless it isn't valid which is what I asked about here)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What changed in 2.7 that caused this issue in the first place?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a swc upgrade.
Input: ["\u0085", "\u200b", "\ufffe", "🙂"];
With 2.6.2: ["\x85", "\u200B", "\uFFFE", "\uD83D\uDE42"]
With 2.7.0: ["\x85", "​", "�", "\uD83D\uDE42"]
With 2.9.0: ["\x85", "​", "�", "\uD83D\uDE42"]

So your concern is already the case, it just doesn't happen for single-codepoint characters (or something like that)

does it turn '🙂' into '\uD83D\uDE42'?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yeah, this PR would restore the behavior from 2.6.2, which is perfectly fine to me and hasn't bothered anyone since.

@mischnic mischnic marked this pull request as draft September 14, 2023 12:24
@parcel-benchmark

parcel-benchmark commented Sep 16, 2023

Copy link
Copy Markdown

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.40s -6.00ms
Cached 268.00ms +18.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/index.b8ae99ba.css 94.00b +0.00b 242.00ms -27.00ms 🚀
dist/modern/index.31cedca9.css 94.00b +0.00b 241.00ms -28.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/index.ff03421b.js 1.48kb +0.00b 340.00ms -20.00ms 🚀
dist/legacy/index.e9bb1616.js 1.06kb +0.00b 340.00ms -19.00ms 🚀
dist/modern/index.4a29d309.js 921.00b +0.00b 340.00ms -19.00ms 🚀

React HackerNews ✅

Timings

Description Time Difference
Cold 3.85s +48.00ms
Cached 386.00ms -18.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/PermalinkedComment.e9dc4a75.js 3.92kb +0.00b 357.00ms +67.00ms ⚠️
dist/UserProfile.8945a243.js 1.38kb +0.00b 357.00ms +68.00ms ⚠️
dist/NotFound.8b44a81d.js 269.00b +0.00b 357.00ms +68.00ms ⚠️
dist/logo.8dd07848.png 244.00b +0.00b 230.00ms +15.00ms ⚠️

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 31.44s -748.00ms
Cached 2.13s +18.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/pdfRenderer.ba28cccc.js 1.11mb +0.00b 11.09s -697.00ms 🚀
dist/refractor.3e0cc31b.js 598.96kb +0.00b 9.91s -524.00ms 🚀
dist/media-viewer.95ebe1bc.js 536.13kb +0.00b 9.91s -524.00ms 🚀
dist/popup.a77286c1.js 321.45kb +0.00b 9.91s -524.00ms 🚀
dist/ConfigPanelFieldsLoader.182d39bc.js 303.43kb +0.00b 6.91s -486.00ms 🚀
dist/EmojiPickerComponent.e0fdf479.js 188.61kb +0.00b 9.91s -534.00ms 🚀
dist/card.d06de810.js 138.91kb +0.00b 6.90s -484.00ms 🚀
dist/ConfigPanelFieldsLoader.0b2d3e5b.js 82.73kb +0.00b 9.88s -561.00ms 🚀
dist/esm.34897092.js 62.95kb +0.00b 9.91s -524.00ms 🚀
dist/ElementBrowser.e8f01080.js 61.94kb +0.00b 6.90s -486.00ms 🚀
dist/archive.c374f622.js 59.90kb +0.00b 9.91s -522.00ms 🚀
dist/esm.692cb9c1.js 59.30kb +0.00b 6.90s -486.00ms 🚀
dist/esm.4df8b361.js 39.11kb +0.00b 9.91s -532.00ms 🚀
dist/smartMediaEditor.efa59853.js 21.68kb +0.00b 9.91s -531.00ms 🚀
dist/esm.1c0d8031.js 20.43kb +0.00b 9.91s -531.00ms 🚀
dist/ConfigPanelFieldsLoader.5903e32b.js 15.74kb +0.00b 6.90s -486.00ms 🚀
dist/ui.8c117104.js 14.48kb +0.00b 6.90s -486.00ms 🚀
dist/ConfigPanelFieldsLoader.cade1f5a.js 13.63kb +0.00b 6.90s -486.00ms 🚀
dist/dropzone.e21a3321.js 13.40kb +0.00b 9.91s -524.00ms 🚀
dist/pdfRenderer.fa30a36a.js 12.04kb +0.00b 9.83s +2.44s ⚠️
dist/dropzone.1c15cdc1.js 11.48kb +0.00b 9.91s -524.00ms 🚀
dist/Toolbar.4d256e97.js 9.36kb +0.00b 9.92s -519.00ms 🚀
dist/clipboard.400013a2.js 7.92kb +0.00b 9.91s -524.00ms 🚀
dist/mobile-upload.3baad8e4.js 7.79kb +0.00b 6.90s -485.00ms 🚀
dist/mobile-upload.7a892a37.js 7.79kb +0.00b 6.90s -486.00ms 🚀
dist/mobile-upload.2102debb.js 7.79kb +0.00b 9.91s -531.00ms 🚀
dist/index.runtime.10b44ee9.js 7.29kb +0.00b 9.92s -554.00ms 🚀
dist/browser.0009c8b4.js 7.19kb +0.00b 9.91s -524.00ms 🚀
dist/index.b16227d6.css 4.08kb +0.00b 9.94s -546.00ms 🚀
dist/media-viewer-analytics-error-boundary.60bdaa4c.js 3.18kb +0.00b 9.91s -524.00ms 🚀
dist/media-picker-analytics-error-boundary.c493f011.js 3.18kb +0.00b 9.91s -525.00ms 🚀
dist/media-card-analytics-error-boundary.74e0c7f9.js 3.18kb +0.00b 9.91s -524.00ms 🚀
dist/ru.0cf3f40e.js 2.81kb +0.00b 6.90s -486.00ms 🚀
dist/uk.282f23b1.js 2.76kb +0.00b 6.90s -487.00ms 🚀
dist/codeViewerRenderer.51140ec8.js 2.61kb +0.00b 9.91s -533.00ms 🚀
dist/th.137e1013.js 2.60kb +0.00b 6.90s -486.00ms 🚀
dist/pl.bce591be.js 2.25kb +0.00b 6.16s +766.00ms ⚠️
dist/vi.b46097db.js 2.09kb +0.00b 6.90s -487.00ms 🚀
dist/pt_BR.b9e37d37.js 2.06kb +0.00b 6.16s +766.00ms ⚠️
dist/tr.c85d90a9.js 2.03kb +0.00b 6.90s -486.00ms 🚀
dist/sv.1c06c95c.js 1.98kb +0.00b 6.90s -486.00ms 🚀
dist/zh_TW.b7c55aa6.js 1.86kb +0.00b 6.90s -487.00ms 🚀
dist/zh.b01fe721.js 1.84kb +0.00b 6.90s -487.00ms 🚀
dist/workerHasher.540c9790.js 1.56kb +0.00b 6.90s -486.00ms 🚀
dist/workerHasher.c840c607.js 1.56kb +0.00b 6.90s -485.00ms 🚀
dist/workerHasher.730f3766.js 1.56kb +0.00b 9.91s -524.00ms 🚀
dist/workerHasher.9b1fcdbf.js 1.56kb +0.00b 9.91s -522.00ms 🚀
dist/workerHasher.02b63a21.js 1.56kb +0.00b 9.91s -531.00ms 🚀
dist/heading3.73972e33.js 1.35kb +0.00b 5.19s +504.00ms ⚠️
dist/heading2.c27d912d.js 1.17kb +0.00b 5.19s +505.00ms ⚠️
dist/heading4.be08fc9e.js 1.12kb +0.00b 5.19s +502.00ms ⚠️
dist/sk.4be9c93f.js 656.00b +0.00b 6.90s -486.00ms 🚀
dist/pt_PT.e211e609.js 635.00b +0.00b 6.16s +766.00ms ⚠️
dist/simpleHasher.c14e20b4.js 589.00b +0.00b 6.90s -486.00ms 🚀
dist/simpleHasher.23db7a52.js 589.00b +0.00b 6.90s -486.00ms 🚀
dist/simpleHasher.eefc98b4.js 589.00b +0.00b 9.91s -524.00ms 🚀
dist/simpleHasher.47b9c809.js 589.00b +0.00b 9.91s -523.00ms 🚀
dist/simpleHasher.cadc19c6.js 589.00b +0.00b 9.91s -531.00ms 🚀
dist/ro.8d5b380a.js 482.00b +0.00b 6.88s -509.00ms 🚀
dist/index.html 248.00b +0.00b 9.98s -505.00ms 🚀

Cached Bundles

No bundle changes detected.

Three.js ✅

Timings

Description Time Difference
Cold 2.82s +15.00ms
Cached 314.00ms -2.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/Three.js 572.22kb +25.00b ⚠️ 931.00ms -8.00ms

Cached Bundles

Bundle Size Difference Time Difference
dist/Three.js 572.22kb +25.00b ⚠️ 897.00ms -22.00ms

Click here to view a detailed benchmark overview.

@mischnic mischnic marked this pull request as ready for review September 16, 2023 13:55
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

Successfully merging this pull request may close these issues.

[webextension] Failed to load extension from: /A. Could not load file B.js for content script. It isn't UTF-8 encoded.

4 participants