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:
@@ -27,8 +27,6 @@ export default function parseAndBuildMetadata<T>(
|
||||
code: string,
|
||||
opts: TemplateOpts,
|
||||
): Metadata {
|
||||
const ast = parseWithCodeFrame(code, opts.parser);
|
||||
|
||||
const {
|
||||
placeholderWhitelist,
|
||||
placeholderPattern,
|
||||
@@ -36,6 +34,8 @@ export default function parseAndBuildMetadata<T>(
|
||||
syntacticPlaceholders,
|
||||
} = opts;
|
||||
|
||||
const ast = parseWithCodeFrame(code, opts.parser, syntacticPlaceholders);
|
||||
|
||||
t.removePropertiesDeep(ast, {
|
||||
preserveComments,
|
||||
});
|
||||
@@ -191,13 +191,19 @@ type MetadataState = {
|
||||
function parseWithCodeFrame(
|
||||
code: string,
|
||||
parserOpts: ParserOpts,
|
||||
syntacticPlaceholders?: boolean,
|
||||
): BabelNodeFile {
|
||||
const plugins = (parserOpts.plugins || []).slice();
|
||||
if (syntacticPlaceholders !== false) {
|
||||
plugins.push("placeholders");
|
||||
}
|
||||
|
||||
parserOpts = {
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
sourceType: "module",
|
||||
...parserOpts,
|
||||
plugins: (parserOpts.plugins || []).concat("placeholders"),
|
||||
plugins,
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user