Respect the jsescOption.minimal generator option (#12755)
This commit is contained in:
parent
a0e3ef2117
commit
77d46bcb1a
@ -58,7 +58,7 @@ function normalizeOptions(code, opts): Format {
|
||||
jsescOption: {
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
minimal: true,
|
||||
minimal: process.env.BABEL_8_BREAKING ? true : false,
|
||||
...opts.jsescOption,
|
||||
},
|
||||
recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType,
|
||||
@ -66,7 +66,6 @@ function normalizeOptions(code, opts): Format {
|
||||
|
||||
if (!process.env.BABEL_8_BREAKING) {
|
||||
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;
|
||||
delete format.jsescOption.minimal;
|
||||
}
|
||||
|
||||
if (format.minified) {
|
||||
|
||||
@ -700,6 +700,30 @@ describe("programmatic generation", function () {
|
||||
expect(output).toBe("export default (class {});");
|
||||
});
|
||||
});
|
||||
|
||||
describe("jsescOption.minimal", () => {
|
||||
const string = t.stringLiteral("\u8868\u683C_\u526F\u672C");
|
||||
|
||||
it("true", () => {
|
||||
const output = generate(string, { jsescOption: { minimal: true } }).code;
|
||||
expect(output).toBe(`"表格_副本"`);
|
||||
});
|
||||
|
||||
it("false", () => {
|
||||
const output = generate(string, { jsescOption: { minimal: false } }).code;
|
||||
expect(output).toBe(`"\\u8868\\u683C_\\u526F\\u672C"`);
|
||||
});
|
||||
|
||||
it("default", () => {
|
||||
const output = generate(string).code;
|
||||
|
||||
if (process.env.BABEL_8_BREAKING) {
|
||||
expect(output).toBe(`"表格_副本"`);
|
||||
} else {
|
||||
expect(output).toBe(`"\\u8868\\u683C_\\u526F\\u672C"`);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("CodeGenerator", function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user