Skip to content

Commit

Permalink
Partial revert of changes needed to build with Babel 8 (#16036)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Oct 13, 2023
1 parent 0ba00c4 commit a345a10
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions babel.config.js
Expand Up @@ -11,6 +11,7 @@ if (

const pathUtils = require("path");
const fs = require("fs");
const { parseSync } = require("@babel/core");

function normalize(src) {
return src.replace(/\//, pathUtils.sep);
Expand Down Expand Up @@ -832,13 +833,11 @@ function pluginReplaceTSImportExtension() {
};
}

function pluginBabelParserTokenType({
parseSync,
types: { isIdentifier, numericLiteral },
}) {
const tokenTypeSourcePath = "./packages/babel-parser/src/tokenizer/types.ts";
function getTokenTypesMapping() {
const tokenTypesMapping = new Map();
const tokenTypesMapping = new Map();
const tokenTypeSourcePath = "./packages/babel-parser/src/tokenizer/types.ts";

function getTokenTypesMapping() {
if (tokenTypesMapping.size === 0) {
const tokenTypesAst = parseSync(
fs.readFileSync(tokenTypeSourcePath, {
encoding: "utf-8",
Expand Down Expand Up @@ -872,9 +871,13 @@ function pluginBabelParserTokenType({
for (let i = 0; i < tokenTypesDefinition.length; i++) {
tokenTypesMapping.set(tokenTypesDefinition[i].key.name, i);
}
return tokenTypesMapping;
}
return tokenTypesMapping;
}

function pluginBabelParserTokenType({
types: { isIdentifier, numericLiteral },
}) {
const tokenTypesMapping = getTokenTypesMapping();
return {
visitor: {
Expand Down

0 comments on commit a345a10

Please sign in to comment.