[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:
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
0;// Not a directive
|
||||
"\u00A9";
|
||||
"©";
|
||||
|
||||
18
packages/babel-generator/test/fixtures/minified/literals-babel-7/input.js
vendored
Normal file
18
packages/babel-generator/test/fixtures/minified/literals-babel-7/input.js
vendored
Normal 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;
|
||||
3
packages/babel-generator/test/fixtures/minified/literals-babel-7/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/minified/literals-babel-7/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/minified/literals-babel-7/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/minified/literals-babel-7/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
5;5;50;5e4;"foobar";" ";"\n\r";"\uD83D\uDE02";"\uD83D_\uDE02"`😂`;/foobar/g;null;true;false;5;2;56;31;
|
||||
@@ -6,6 +6,7 @@
|
||||
'\x20';
|
||||
"\n\r";
|
||||
"😂";
|
||||
"\uD83D_\uDE02"
|
||||
`😂`;
|
||||
/foobar/g;
|
||||
null;
|
||||
|
||||
3
packages/babel-generator/test/fixtures/minified/literals/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/minified/literals/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user