Allow templates to parse v8intrinsics (#11695)
* Allow templates to parse v8intrinsics The `v8intrinsic` and `placeholders` parser plugins conflict, so enabling `placeholders` unconditionally was causing errors for V8's internal codemods. This allows them to set `syntacticPlaceholders = false` (so they'll use the legacy identifier format) and enable `v8intrinsic` by itself. * Fix linter * Linter
This commit is contained in:
@@ -294,6 +294,17 @@ describe("@babel/template", function () {
|
||||
template(`%%FOO%%`, { syntacticPlaceholders: false })({
|
||||
FOO: t.numericLiteral(1),
|
||||
});
|
||||
}).toThrow(/Unexpected token.*/);
|
||||
});
|
||||
|
||||
it("disallow manually enabled placeholders", () => {
|
||||
expect(() => {
|
||||
template(`%%FOO%%`, {
|
||||
syntacticPlaceholders: false,
|
||||
plugins: ["placeholders"],
|
||||
})({
|
||||
FOO: t.numericLiteral(1),
|
||||
});
|
||||
}).toThrow(/%%.*placeholders can't be used/);
|
||||
});
|
||||
|
||||
@@ -303,6 +314,16 @@ describe("@babel/template", function () {
|
||||
});
|
||||
expect(generator(output).code).toMatchInlineSnapshot(`"1;"`);
|
||||
});
|
||||
|
||||
it("allows v8intrinsics", () => {
|
||||
const output = template(`%DebugPrint(1)`, {
|
||||
syntacticPlaceholders: false,
|
||||
plugins: ["v8intrinsic"],
|
||||
})();
|
||||
expect(generator(output).code).toMatchInlineSnapshot(
|
||||
`"%DebugPrint(1);"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("undefined", () => {
|
||||
|
||||
Reference in New Issue
Block a user