Bundle "Experimental CLI" (#17396)
This commit is contained in:
1 parent
59c635b939
commit
d4fd92e266
19 files changed
+303
-103
No files matched your search
@@ -100,15 +100,6 @@ async function buildPackageJson({ packageConfig, file }) {
|
||||
prepublishOnly:
|
||||
"node -e \"assert.equal(require('.').version, require('..').version)\"",
|
||||
},
|
||||
peerDependencies: {
|
||||
// Add `^` here, so we don't need release Prettier user can still update CLI
|
||||
"@prettier/cli": `^${packageJson.dependencies["@prettier/cli"]}`,
|
||||
},
|
||||
peerDependenciesMeta: {
|
||||
"@prettier/cli": {
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
await writeJson(
|
||||
|
||||
+59
-3
@@ -786,11 +786,19 @@ const nodejsFiles = [
|
||||
replaceModule: [
|
||||
{
|
||||
module: path.join(PROJECT_ROOT, "bin/prettier.cjs"),
|
||||
process: (text) =>
|
||||
text.replace("../src/cli/index.js", "../internal/legacy-cli.mjs"),
|
||||
process(text) {
|
||||
text = text.replace(
|
||||
"../src/cli/index.js",
|
||||
"../internal/legacy-cli.mjs",
|
||||
);
|
||||
text = text.replace(
|
||||
"../src/experimental-cli/index.js",
|
||||
"../internal/experimental-cli.mjs",
|
||||
);
|
||||
return text;
|
||||
},
|
||||
},
|
||||
],
|
||||
external: ["@prettier/cli"],
|
||||
},
|
||||
{
|
||||
input: "src/cli/index.js",
|
||||
@@ -811,6 +819,54 @@ const nodejsFiles = [
|
||||
},
|
||||
],
|
||||
},
|
||||
...[
|
||||
{
|
||||
input: "src/experimental-cli/index.js",
|
||||
outputBaseName: "internal/experimental-cli",
|
||||
replaceModule: [
|
||||
{
|
||||
module: getPackageFile("@prettier/cli/dist/prettier_serial.js"),
|
||||
external: "./experimental-cli-worker.mjs",
|
||||
},
|
||||
{
|
||||
module: getPackageFile("@prettier/cli/dist/prettier_parallel.js"),
|
||||
find: 'new URL("./prettier_serial.js", import.meta.url)',
|
||||
replacement:
|
||||
'new URL("./experimental-cli-worker.mjs", import.meta.url)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "src/experimental-cli/worker.js",
|
||||
outputBaseName: "internal/experimental-cli-worker",
|
||||
},
|
||||
].map(({ input, outputBaseName, replaceModule = [] }) => ({
|
||||
input,
|
||||
outputBaseName,
|
||||
replaceModule: [
|
||||
...replaceModule,
|
||||
{
|
||||
module: getPackageFile("@prettier/cli/dist/constants.js"),
|
||||
path: path.join(
|
||||
PROJECT_ROOT,
|
||||
"src/experimental-cli/constants.evaluate.js",
|
||||
),
|
||||
},
|
||||
...[
|
||||
"package.json",
|
||||
"index.mjs",
|
||||
...universalFiles
|
||||
.filter(
|
||||
({ kind, output }) =>
|
||||
kind === "javascript" && output.format === "esm",
|
||||
)
|
||||
.map(({ output }) => output.file),
|
||||
].map((file) => ({
|
||||
module: getPackageFile(`prettier/${file}`),
|
||||
external: `../${file}`,
|
||||
})),
|
||||
],
|
||||
})),
|
||||
].flatMap((file) => {
|
||||
let { input, output, outputBaseName, ...buildOptions } = file;
|
||||
|
||||
|
||||
Reference in new issue
Block a user