[babel 8] Output minimal strings by default (#12675)

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Justin Ridgewell <jridgewell@google.com>
This commit is contained in:
Huáng Jùnliàng
2021-01-23 16:50:07 -05:00
committed by GitHub
parent 464a02ffe1
commit cd090e9842
37 changed files with 231 additions and 12 deletions

View File

@@ -20,7 +20,7 @@
],
"dependencies": {
"@babel/types": "workspace:^7.12.11",
"jsesc": "^2.5.1",
"jsesc": "condition: BABEL_8_BREAKING ? ^3.0.2 : ^2.5.1",
"source-map": "^0.5.0"
},
"devDependencies": {

View File

@@ -203,8 +203,6 @@ export function StringLiteral(node: Object) {
return;
}
// ensure the output is ASCII-safe
const val = jsesc(
node.value,
process.env.BABEL_8_BREAKING

View File

@@ -55,6 +55,7 @@ function normalizeOptions(code, opts): Format {
jsescOption: {
quotes: "double",
wrap: true,
minimal: true,
...opts.jsescOption,
},
recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType,
@@ -62,6 +63,7 @@ function normalizeOptions(code, opts): Format {
if (!process.env.BABEL_8_BREAKING) {
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;
delete format.jsescOption.minimal;
}
if (format.minified) {

View File

@@ -1,2 +1,2 @@
0;// Not a directive
"\u00A9";
"©";

View File

@@ -0,0 +1,18 @@
5;
5.0;
5e1;
5e4;
"foobar";
'\x20';
"\n\r";
"😂";
"\uD83D_\uDE02"
`😂`;
/foobar/g;
null;
true;
false;
5.;
0b10;
0o70;
0X1F;

View File

@@ -0,0 +1,3 @@
{
"BABEL_8_BREAKING": false
}

View File

@@ -0,0 +1 @@
5;5;50;5e4;"foobar";" ";"\n\r";"\uD83D\uDE02";"\uD83D_\uDE02"`😂`;/foobar/g;null;true;false;5;2;56;31;

View File

@@ -6,6 +6,7 @@
'\x20';
"\n\r";
"😂";
"\uD83D_\uDE02"
`😂`;
/foobar/g;
null;

View File

@@ -0,0 +1,3 @@
{
"BABEL_8_BREAKING": true
}

View File

@@ -1 +1 @@
5;5;50;5e4;"foobar";" ";"\n\r";"\uD83D\uDE02";`😂`;/foobar/g;null;true;false;5;2;56;31;
5;5;50;5e4;"foobar";" ";"\n\r";"😂";"\uD83D_\uDE02"`😂`;/foobar/g;null;true;false;5;2;56;31;