diff --git a/packages/babel-generator/package.json b/packages/babel-generator/package.json
index 55669fb555..f938349f6c 100644
--- a/packages/babel-generator/package.json
+++ b/packages/babel-generator/package.json
@@ -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": {
diff --git a/packages/babel-generator/src/generators/types.js b/packages/babel-generator/src/generators/types.js
index c3681cd2e5..3a074b7598 100644
--- a/packages/babel-generator/src/generators/types.js
+++ b/packages/babel-generator/src/generators/types.js
@@ -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
diff --git a/packages/babel-generator/src/index.js b/packages/babel-generator/src/index.js
index da2eb2b3a1..588208acca 100644
--- a/packages/babel-generator/src/index.js
+++ b/packages/babel-generator/src/index.js
@@ -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) {
diff --git a/packages/babel-generator/test/fixtures/escapes/jsonEscape/output.js b/packages/babel-generator/test/fixtures/escapes/jsonEscape/output.js
index 4da42cb397..361472ec13 100644
--- a/packages/babel-generator/test/fixtures/escapes/jsonEscape/output.js
+++ b/packages/babel-generator/test/fixtures/escapes/jsonEscape/output.js
@@ -1,2 +1,2 @@
0;// Not a directive
-"\u00A9";
\ No newline at end of file
+"漏";
diff --git a/packages/babel-generator/test/fixtures/minified/literals-babel-7/input.js b/packages/babel-generator/test/fixtures/minified/literals-babel-7/input.js
new file mode 100644
index 0000000000..8799ed5e7c
--- /dev/null
+++ b/packages/babel-generator/test/fixtures/minified/literals-babel-7/input.js
@@ -0,0 +1,18 @@
+5;
+5.0;
+5e1;
+5e4;
+"foobar";
+'\x20';
+"\n\r";
+"馃槀";
+"\uD83D_\uDE02"
+`馃槀`;
+/foobar/g;
+null;
+true;
+false;
+5.;
+0b10;
+0o70;
+0X1F;
diff --git a/packages/babel-generator/test/fixtures/minified/literals-babel-7/options.json b/packages/babel-generator/test/fixtures/minified/literals-babel-7/options.json
new file mode 100644
index 0000000000..29a3f0e841
--- /dev/null
+++ b/packages/babel-generator/test/fixtures/minified/literals-babel-7/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": false
+}
diff --git a/packages/babel-generator/test/fixtures/minified/literals-babel-7/output.js b/packages/babel-generator/test/fixtures/minified/literals-babel-7/output.js
new file mode 100644
index 0000000000..4f2198881a
--- /dev/null
+++ b/packages/babel-generator/test/fixtures/minified/literals-babel-7/output.js
@@ -0,0 +1 @@
+5;5;50;5e4;"foobar";" ";"\n\r";"\uD83D\uDE02";"\uD83D_\uDE02"`馃槀`;/foobar/g;null;true;false;5;2;56;31;
\ No newline at end of file
diff --git a/packages/babel-generator/test/fixtures/minified/literals/input.js b/packages/babel-generator/test/fixtures/minified/literals/input.js
index 42ffdc30a3..8799ed5e7c 100644
--- a/packages/babel-generator/test/fixtures/minified/literals/input.js
+++ b/packages/babel-generator/test/fixtures/minified/literals/input.js
@@ -6,6 +6,7 @@
'\x20';
"\n\r";
"馃槀";
+"\uD83D_\uDE02"
`馃槀`;
/foobar/g;
null;
diff --git a/packages/babel-generator/test/fixtures/minified/literals/options.json b/packages/babel-generator/test/fixtures/minified/literals/options.json
new file mode 100644
index 0000000000..cbf6d15954
--- /dev/null
+++ b/packages/babel-generator/test/fixtures/minified/literals/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": true
+}
diff --git a/packages/babel-generator/test/fixtures/minified/literals/output.js b/packages/babel-generator/test/fixtures/minified/literals/output.js
index a44147f006..2fe5ac6abc 100644
--- a/packages/babel-generator/test/fixtures/minified/literals/output.js
+++ b/packages/babel-generator/test/fixtures/minified/literals/output.js
@@ -1 +1 @@
-5;5;50;5e4;"foobar";" ";"\n\r";"\uD83D\uDE02";`馃槀`;/foobar/g;null;true;false;5;2;56;31;
\ No newline at end of file
+5;5;50;5e4;"foobar";" ";"\n\r";"馃槀";"\uD83D_\uDE02"`馃槀`;/foobar/g;null;true;false;5;2;56;31;
\ No newline at end of file
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/input.js
new file mode 100644
index 0000000000..addae3b9f8
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/input.js
@@ -0,0 +1,3 @@
+
;
+;
+;
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/options.json
new file mode 100644
index 0000000000..29a3f0e841
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": false
+}
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/output.mjs b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/output.mjs
new file mode 100644
index 0000000000..9a5aedeff4
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute-babel-7/output.mjs
@@ -0,0 +1,16 @@
+import { jsx as _jsx } from "react/jsx-runtime";
+
+/*#__PURE__*/
+_jsx("div", {
+ id: "w\xF4w"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ id: "\\w"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ id: "w < w"
+});
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/options.json
new file mode 100644
index 0000000000..cbf6d15954
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": true
+}
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/output.mjs b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/output.mjs
index 9a5aedeff4..df67646393 100644
--- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/output.mjs
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxattribute/output.mjs
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
/*#__PURE__*/
_jsx("div", {
- id: "w\xF4w"
+ id: "w么w"
});
/*#__PURE__*/
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/input.js
new file mode 100644
index 0000000000..2104766109
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/input.js
@@ -0,0 +1,12 @@
+wow
;
+w么w
;
+
+w & w
;
+w & w
;
+
+w w
;
+this should not parse as unicode: \u00a0
;
+this should parse as nbsp: 聽
;
+this should parse as unicode: {'\u00a0聽'}
;
+
+w < w
;
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/options.json
new file mode 100644
index 0000000000..3849cb9189
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/options.json
@@ -0,0 +1 @@
+{ "BABEL_8_BREAKING": false }
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/output.mjs b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/output.mjs
new file mode 100644
index 0000000000..4c325c34bd
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext-babel-7/output.mjs
@@ -0,0 +1,47 @@
+import { jsx as _jsx } from "react/jsx-runtime";
+import { jsxs as _jsxs } from "react/jsx-runtime";
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "wow"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "w\xF4w"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "w & w"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "w & w"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "w \xA0 w"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "this should not parse as unicode: \\u00a0"
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "this should parse as nbsp: \xA0 "
+});
+
+/*#__PURE__*/
+_jsxs("div", {
+ children: ["this should parse as unicode: ", '\u00a0聽']
+});
+
+/*#__PURE__*/
+_jsx("div", {
+ children: "w < w"
+});
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/options.json
new file mode 100644
index 0000000000..bb276f46d2
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/options.json
@@ -0,0 +1 @@
+{ "BABEL_8_BREAKING": true }
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/output.mjs b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/output.mjs
index 4c325c34bd..0c7002dd6a 100644
--- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/output.mjs
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/should-escape-xhtml-jsxtext/output.mjs
@@ -8,7 +8,7 @@ _jsx("div", {
/*#__PURE__*/
_jsx("div", {
- children: "w\xF4w"
+ children: "w么w"
});
/*#__PURE__*/
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/input.js
new file mode 100644
index 0000000000..addae3b9f8
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/input.js
@@ -0,0 +1,3 @@
+;
+;
+;
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/options.json
new file mode 100644
index 0000000000..29a3f0e841
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": false
+}
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/output.js
new file mode 100644
index 0000000000..60f6fd9294
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute-babel-7/output.js
@@ -0,0 +1,14 @@
+/*#__PURE__*/
+React.createElement("div", {
+ id: "w\xF4w"
+});
+
+/*#__PURE__*/
+React.createElement("div", {
+ id: "\\w"
+});
+
+/*#__PURE__*/
+React.createElement("div", {
+ id: "w < w"
+});
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/options.json
new file mode 100644
index 0000000000..cbf6d15954
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": true
+}
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/output.js
index 60f6fd9294..a72c88050e 100644
--- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/output.js
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxattribute/output.js
@@ -1,6 +1,6 @@
/*#__PURE__*/
React.createElement("div", {
- id: "w\xF4w"
+ id: "w么w"
});
/*#__PURE__*/
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/input.js
new file mode 100644
index 0000000000..2104766109
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/input.js
@@ -0,0 +1,12 @@
+wow
;
+w么w
;
+
+w & w
;
+w & w
;
+
+w w
;
+this should not parse as unicode: \u00a0
;
+this should parse as nbsp: 聽
;
+this should parse as unicode: {'\u00a0聽'}
;
+
+w < w
;
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/options.json
new file mode 100644
index 0000000000..29a3f0e841
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": false
+}
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/output.js
new file mode 100644
index 0000000000..64f33c7253
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext-babel-7/output.js
@@ -0,0 +1,26 @@
+/*#__PURE__*/
+React.createElement("div", null, "wow");
+
+/*#__PURE__*/
+React.createElement("div", null, "w\xF4w");
+
+/*#__PURE__*/
+React.createElement("div", null, "w & w");
+
+/*#__PURE__*/
+React.createElement("div", null, "w & w");
+
+/*#__PURE__*/
+React.createElement("div", null, "w \xA0 w");
+
+/*#__PURE__*/
+React.createElement("div", null, "this should not parse as unicode: \\u00a0");
+
+/*#__PURE__*/
+React.createElement("div", null, "this should parse as nbsp: \xA0 ");
+
+/*#__PURE__*/
+React.createElement("div", null, "this should parse as unicode: ", '\u00a0聽');
+
+/*#__PURE__*/
+React.createElement("div", null, "w < w");
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/options.json
new file mode 100644
index 0000000000..cbf6d15954
--- /dev/null
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": true
+}
diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/output.js
index 64f33c7253..1edc53edeb 100644
--- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/output.js
+++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/should-escape-xhtml-jsxtext/output.js
@@ -2,7 +2,7 @@
React.createElement("div", null, "wow");
/*#__PURE__*/
-React.createElement("div", null, "w\xF4w");
+React.createElement("div", null, "w么w");
/*#__PURE__*/
React.createElement("div", null, "w & w");
diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/input.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/input.js
new file mode 100644
index 0000000000..d705d76c35
--- /dev/null
+++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/input.js
@@ -0,0 +1 @@
+var foo = bar`\u0061\u{0061}\ud835\udc9c\u{1d49c}`;
diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/options.json b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/options.json
new file mode 100644
index 0000000000..29a3f0e841
--- /dev/null
+++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": false
+}
diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/output.js
new file mode 100644
index 0000000000..84eb40577d
--- /dev/null
+++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes-babel-7/output.js
@@ -0,0 +1,5 @@
+var _templateObject;
+
+function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+var foo = bar(_templateObject || (_templateObject = _taggedTemplateLiteral(["aa\uD835\uDC9C\uD835\uDC9C"], ["\\u0061\\u{0061}\\ud835\\udc9c\\u{1d49c}"])));
diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/options.json b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/options.json
new file mode 100644
index 0000000000..cbf6d15954
--- /dev/null
+++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/options.json
@@ -0,0 +1,3 @@
+{
+ "BABEL_8_BREAKING": true
+}
diff --git a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/output.js b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/output.js
index 84eb40577d..5c3b289ffc 100644
--- a/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/output.js
+++ b/packages/babel-plugin-transform-template-literals/test/fixtures/default/tag-with-unicode-escapes/output.js
@@ -2,4 +2,4 @@ var _templateObject;
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-var foo = bar(_templateObject || (_templateObject = _taggedTemplateLiteral(["aa\uD835\uDC9C\uD835\uDC9C"], ["\\u0061\\u{0061}\\ud835\\udc9c\\u{1d49c}"])));
+var foo = bar(_templateObject || (_templateObject = _taggedTemplateLiteral(["aa饾挏饾挏"], ["\\u0061\\u{0061}\\ud835\\udc9c\\u{1d49c}"])));
diff --git a/packages/babel-plugin-transform-unicode-escapes/src/index.js b/packages/babel-plugin-transform-unicode-escapes/src/index.js
index bfb38422aa..f21e9cfdaf 100644
--- a/packages/babel-plugin-transform-unicode-escapes/src/index.js
+++ b/packages/babel-plugin-transform-unicode-escapes/src/index.js
@@ -42,6 +42,15 @@ export default declare(api => {
return {
name: "transform-unicode-escapes",
+ manipulateOptions({ generatorOpts }) {
+ // Babel 8 will enable jsesc minimal mode by default, which outputs
+ // unescaped unicode string
+ if (!generatorOpts.jsescOption) {
+ generatorOpts.jsescOption = {};
+ }
+ // $FlowIgnore: Flow does not support logical assignment
+ generatorOpts.jsescOption.minimal ??= false;
+ },
visitor: {
Identifier(path) {
const { node, key } = path;
diff --git a/yarn.lock b/yarn.lock
index d2b0c76ee7..fd81c0ff99 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -251,7 +251,7 @@ __metadata:
"@babel/helper-fixtures": "workspace:*"
"@babel/parser": "workspace:*"
"@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
languageName: unknown
linkType: soft
@@ -9210,7 +9210,7 @@ fsevents@^1.2.7:
languageName: node
linkType: hard
-"jsesc@npm:^2.5.1":
+"jsesc-BABEL_8_BREAKING-false@npm:jsesc@^2.5.1, jsesc@npm:^2.5.1":
version: 2.5.2
resolution: "jsesc@npm:2.5.2"
bin:
@@ -9219,6 +9219,25 @@ fsevents@^1.2.7:
languageName: node
linkType: hard
+"jsesc-BABEL_8_BREAKING-true@npm:jsesc@^3.0.2":
+ version: 3.0.2
+ resolution: "jsesc@npm:3.0.2"
+ bin:
+ jsesc: bin/jsesc
+ checksum: 809c7663241f76c42528e2706f011d43c0eaa19b50a5d6f4015b4b9563292c0ffad1f5b12a9a41b71e2206efc5ae3632e8b27c35cb3ef508c0a58a3bb011da90
+ languageName: node
+ linkType: hard
+
+"jsesc@condition: BABEL_8_BREAKING ? ^3.0.2 : ^2.5.1":
+ version: 0.0.0-condition-31d9b4
+ resolution: "jsesc@condition:BABEL_8_BREAKING?^3.0.2:^2.5.1#31d9b4"
+ dependencies:
+ jsesc-BABEL_8_BREAKING-false: "npm:jsesc@^2.5.1"
+ jsesc-BABEL_8_BREAKING-true: "npm:jsesc@^3.0.2"
+ checksum: d6751e397e85958087fffcb6fbe5892902d2455e98ff0d69b69d0b15103892465d60aa0d750199a5d45cca75bbd89c4854b80ef4cbb98b229e3e9fa4e567d968
+ languageName: node
+ linkType: hard
+
"jsesc@npm:~0.5.0":
version: 0.5.0
resolution: "jsesc@npm:0.5.0"