Skip to content

Commit

Permalink
Simplify test script
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Mar 18, 2022
1 parent 76d9ecc commit 23004ca
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions scripts/tools/bundle-prettier-with-webpack-test/index.js
@@ -1,6 +1,5 @@
import { fileURLToPath } from "node:url";
import path from "node:path";
import fs from "node:fs/promises";
import crypto from "node:crypto";
import webpack from "webpack";
import { DIST_DIR } from "../../../scripts/utils/index.mjs";
Expand Down Expand Up @@ -33,27 +32,12 @@ const TEMPORARY_DIRECTORY = fileURLToPath(new URL("./.tmp", import.meta.url));

/* `require` in `parser-typescript.js`, #12338 */
(async () => {
try {
await fs.mkdir(TEMPORARY_DIRECTORY);
} catch {
// No op
}

const relativePath = path
.relative(TEMPORARY_DIRECTORY, DIST_DIR)
.replaceAll("\\", "/");

const PROBLEMATIC_WARNING_MESSAGE =
"Critical dependency: require function is used in a way in which dependencies cannot be statically extracted";
const inputFile = path.join(TEMPORARY_DIRECTORY, getRandomFileName("input"));
await fs.writeFile(
inputFile,
`import "${relativePath}/parser-typescript.js"`
);

const stats = await runWebpack({
mode: "production",
entry: inputFile,
entry: path.join(DIST_DIR, "parser-typescript.js"),
output: {
path: TEMPORARY_DIRECTORY,
filename: getRandomFileName("output"),
Expand Down

0 comments on commit 23004ca

Please sign in to comment.