Use native ESM for dev scripts (#12296)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
Karan Sapolia
2021-01-30 23:06:21 +05:30
committed by GitHub
parent f8fe8eaab1
commit b63be942ce
39 changed files with 205 additions and 193 deletions

View File

@@ -1,7 +1,10 @@
const fs = require("fs").promises;
const path = require("path");
const merge = require("mergeiterator");
const TestRunner = require("../utils/parser-test-runner");
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from "url";
import merge from "mergeiterator";
import TestRunner from "../utils/parser-test-runner.js";
const dirname = path.dirname(fileURLToPath(import.meta.url));
const flowOptionsMapping = {
esproposal_class_instance_fields: "classProperties",
@@ -88,8 +91,8 @@ async function* loadTests(root) {
}
const runner = new TestRunner({
testDir: path.join(__dirname, "../../../build/flow/src/parser/test/flow"),
allowlist: path.join(__dirname, "allowlist.txt"),
testDir: path.join(dirname, "../../../build/flow/src/parser/test/flow"),
allowlist: path.join(dirname, "allowlist.txt"),
shouldUpdate: process.argv.includes("--update-allowlist"),
async *getTests() {

View File

@@ -1,6 +1,9 @@
const path = require("path");
const TestStream = require("test262-stream");
const TestRunner = require("../utils/parser-test-runner");
import path from "path";
import { fileURLToPath } from "url";
import TestStream from "test262-stream";
import TestRunner from "../utils/parser-test-runner.js";
const dirname = path.dirname(fileURLToPath(import.meta.url));
const ignoredFeatures = [
"__getter__",
@@ -163,8 +166,8 @@ function* getPlugins(features) {
}
const runner = new TestRunner({
testDir: path.join(__dirname, "../../../build/test262"),
allowlist: path.join(__dirname, "allowlist.txt"),
testDir: path.join(dirname, "../../../build/test262"),
allowlist: path.join(dirname, "allowlist.txt"),
logInterval: 500,
shouldUpdate: process.argv.includes("--update-allowlist"),

View File

@@ -8,7 +8,7 @@ Note that babel-parser should not throw for the TypeChecking Diagnostics
The commented out diagnostic codes will introduce false positive cases that should be addressed in separate PRs.
*/
module.exports = [
export default [
// "TS1005", // '{0}' expected.
"TS1009", // Trailing comma not allowed.
"TS1014", // A rest parameter must be last in a parameter list.

View File

@@ -1,8 +1,11 @@
const path = require("path");
const fs = require("fs").promises;
const ts = require("../../../build/typescript");
const TestRunner = require("../utils/parser-test-runner");
const parsingErrorCodes = require("./error-codes");
import path from "path";
import fs from "fs/promises";
import { fileURLToPath } from "url";
import ts from "../../../build/typescript/lib/typescript.js";
import TestRunner from "../utils/parser-test-runner.js";
import parsingErrorCodes from "./error-codes.js";
const dirname = path.dirname(fileURLToPath(import.meta.url));
async function* loadTests(dir) {
const names = await fs.readdir(dir);
@@ -21,7 +24,7 @@ const plugins = [
"dynamicImport",
];
const TSTestsPath = path.join(__dirname, "../../../build/typescript/tests");
const TSTestsPath = path.join(dirname, "../../../build/typescript/tests");
// Check if the baseline errors contain the codes that should also be thrown from babel-parser
async function baselineContainsParserErrorCodes(testName) {
@@ -45,7 +48,7 @@ async function baselineContainsParserErrorCodes(testName) {
const runner = new TestRunner({
testDir: path.join(TSTestsPath, "./cases/compiler"),
allowlist: path.join(__dirname, "allowlist.txt"),
allowlist: path.join(dirname, "allowlist.txt"),
logInterval: 50,
shouldUpdate: process.argv.includes("--update-allowlist"),

View File

@@ -1,8 +1,6 @@
"use strict";
const fs = require("fs").promises;
const chalk = require("chalk");
const { parse: parser } = require("../../../packages/babel-parser");
import fs from "fs/promises";
import chalk from "chalk";
import { parse as parser } from "../../../packages/babel-parser/lib/index.js";
const dot = chalk.gray(".");
@@ -234,4 +232,4 @@ class TestRunner {
}
}
module.exports = exports = TestRunner;
export default TestRunner;