feat(codegen)!: print StringLiteral raw if minify option disabled#10553
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
CodSpeed Instrumentation Performance ReportMerging #10553 will create unknown performance changesComparing Summary
Benchmarks breakdown
|
|
The failing test is https://github.com/oxc-project/oxc/tree/7e712820e9d19d2b1293b7e8ffe9f4275a34323c/tasks/transform_conformance/tests/babel-preset-typescript/test/fixtures/removeImportExtensions -import "./a";
-import "./a";
-import "./a";
-import "./react";
+import "./a.ts";
+import "./a.mts";
+import "./a.cts";
+import "./react.tsx";
-import "a-package/file";
+import "a-package/file.ts";My guess is we are altering the @Dunqing Does that sound possible? |
0ba9775 to
bc921a4
Compare
940fa1f to
efbdc0a
Compare
|
Yes, that was it. Fixed in #10554. |
Merge activity
|
…ed (#10553) Closes #10214. When `options.minify` is `false`, print raw `StringLiteral` as unchanged as possible from how it appeared in source code. But still obey `options.single_quotes`. * If `options.single_quotes == true` and string was originally quoted with `'`, print raw string unchanged. * If `options.single_quotes == false` and string was originally quoted with `"`, print raw string unchanged. * Otherwise, alter the quotes to those requested, and escape any quotes as required within the raw string content. Do not escape or unescape any other characters. * If `StringLiteral` has no `raw` representation, encode from `value`, using the quote character requested and escape characters as required (like when `options.minify` is `true`).
efbdc0a to
14bb2be
Compare
bc921a4 to
10e1018
Compare
… `minify` option disabled (#10553) (#10569) This reverts commit 10e1018. After experimenting with downstream crates like Rolldown, I discovered this introduces a footgun. It's really easy to change `StringLiteral::value` without also changing `StringLiteral::raw`, which results in incorrect codegen. After some consideration, I've decided against introducing an extra option for printing the raw value, it adds a significant amount of maintenance burden. (This issue alone is already consuming a lot of our time). We will need to three modes in the codegen: normal, minify and raw. For now, let's assume our codegen will not preserve the original source text. If preserving the original source text is a requirement, please use magic string or any other direct string manipulation methods.

Closes #10214.
When
options.minifyisfalse, print rawStringLiteralas unchanged as possible from how it appeared in source code. But still obeyoptions.single_quotes.options.single_quotes == trueand string was originally quoted with', print raw string unchanged.options.single_quotes == falseand string was originally quoted with", print raw string unchanged.StringLiteralhas norawrepresentation, encode fromvalue, using the quote character requested and escape characters as required (like whenoptions.minifyistrue).