|
1 | | -import { createRequire } from "node:module"; |
2 | 1 | import path from "node:path"; |
3 | 2 | import createEsmUtils from "esm-utils"; |
4 | | -import { satisfies } from "semver"; |
5 | | -import getPrettier from "./get-prettier.js"; |
6 | 3 |
|
7 | 4 | const { __dirname } = createEsmUtils(import.meta); |
8 | 5 |
|
9 | 6 | async function getPluginsInternal() { |
10 | | - if (!process.env.TEST_STANDALONE) { |
11 | | - return [path.join(__dirname, "../../src/index.ts")]; |
12 | | - } |
13 | | - |
14 | | - const require = createRequire(import.meta.url); |
15 | | - const prettier = await getPrettier(); |
16 | | - |
17 | | - const prettierPath = path.dirname(require.resolve("prettier")); |
18 | | - const pluginPrefix = satisfies(prettier.version, "^2.3.0") |
19 | | - ? "parser-" // Prettier V2 |
20 | | - : "plugins/"; // Prettier V3 |
21 | | - const babel = path.join(prettierPath, `${pluginPrefix}babel.js`); |
22 | | - const markdown = path.join(prettierPath, `${pluginPrefix}markdown.js`); |
23 | | - const standalone = path.join(__dirname, "../../dist/standalone.js"); |
24 | | - |
25 | | - return [ |
26 | | - (await import(babel)).default, |
27 | | - (await import(markdown)).default, |
28 | | - (await import(standalone)).default, |
29 | | - ]; |
| 7 | + return await Promise.all( |
| 8 | + process.env.TEST_STANDALONE |
| 9 | + ? [ |
| 10 | + import("prettier/plugins/babel"), |
| 11 | + import("prettier/plugins/markdown"), |
| 12 | + import(path.join(__dirname, "../../dist/standalone.js")), |
| 13 | + ] |
| 14 | + : [path.join(__dirname, "../../src/index.ts")], |
| 15 | + ).then((modules) => modules.map((module) => module.default ?? module)); |
30 | 16 | } |
31 | 17 |
|
32 | 18 | let promise; |
|
0 commit comments