Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle package into dist/prettier/ #15825

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/prod-test.yml
Expand Up @@ -135,4 +135,4 @@ jobs:
run: node -v | grep "v0.10.48" || exit 1

- name: Run CLI on Node.js v0.10.48
run: node dist/bin/prettier.cjs --version 2>&1 >/dev/null | grep "prettier requires at least version 14 of Node, please upgrade" || exit 1
run: node dist/prettier/bin/prettier.cjs --version 2>&1 >/dev/null | grep "prettier requires at least version 14 of Node, please upgrade" || exit 1
2 changes: 1 addition & 1 deletion jest.config.js
Expand Up @@ -15,7 +15,7 @@ const SKIP_PRODUCTION_INSTALL = Boolean(process.env.SKIP_PRODUCTION_INSTALL);
const SKIP_TESTS_WITH_NEW_SYNTAX = process.versions.node.startsWith("14.");

let PRETTIER_DIR = isProduction
? path.join(PROJECT_ROOT, "dist")
? path.join(PROJECT_ROOT, "dist/prettier")
: PROJECT_ROOT;
let PRETTIER_INSTALLED_DIR = "";
if (
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -162,8 +162,8 @@
"test:dist": "cross-env NODE_ENV=production yarn test",
"test:dist-standalone": "cross-env TEST_STANDALONE=1 yarn test:dist",
"test:dist-lint": "eslint --no-eslintrc --no-ignore --no-inline-config --config=./scripts/bundle-eslint-config.cjs \"dist/**/*.{js,cjs,mjs}\"",
"perf": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin/prettier.cjs",
"perf:inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin/prettier.cjs",
"perf": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/prettier/bin/prettier.cjs",
"perf:inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/prettier/bin/prettier.cjs",
"perf:benchmark": "yarn perf --debug-benchmark",
"perf:compare": "./scripts/benchmark/compare.sh",
"lint": "run-p \"lint:*\"",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-website.js
Expand Up @@ -27,7 +27,7 @@ const runYarn = (command, args, options) =>
});
const IS_PULL_REQUEST = process.env.PULL_REQUEST === "true";
const PRETTIER_DIR = IS_PULL_REQUEST
? DIST_DIR
? path.join(DIST_DIR, "prettier")
: url.fileURLToPath(new URL("../node_modules/prettier", import.meta.url));
const PLAYGROUND_PRETTIER_DIR = path.join(WEBSITE_DIR, "static/lib");

Expand Down
3 changes: 1 addition & 2 deletions scripts/build/build-license.js
Expand Up @@ -6,7 +6,6 @@ import { outdent } from "outdent";
import { DIST_DIR, PROJECT_ROOT } from "../utils/index.js";

const PROJECT_LICENSE_FILE = path.join(PROJECT_ROOT, "LICENSE");
const LICENSE_FILE = path.join(DIST_DIR, "LICENSE");
const separator = `\n${"-".repeat(40)}\n\n`;

function toBlockQuote(text) {
Expand Down Expand Up @@ -137,7 +136,7 @@ async function buildLicense({ file, files, shouldCollectLicenses }) {

const text = await getLicenseText(javascriptFiles);

await fs.writeFile(LICENSE_FILE, text);
await fs.writeFile(path.join(DIST_DIR, file.output.file), text);
}

export default buildLicense;
11 changes: 6 additions & 5 deletions scripts/build/config.js
Expand Up @@ -24,6 +24,7 @@ const copyFileBuilder = ({ file }) =>
path.join(PROJECT_ROOT, file.input),
path.join(DIST_DIR, file.output.file),
);
const PACKAGE_NAME = "prettier";

function getTypesFileConfig({ input: jsFileInput, outputBaseName, isPlugin }) {
let input = jsFileInput;
Expand All @@ -38,7 +39,7 @@ function getTypesFileConfig({ input: jsFileInput, outputBaseName, isPlugin }) {
return {
input,
output: {
file: outputBaseName + ".d.ts",
file: `${PACKAGE_NAME}/${outputBaseName}.d.ts`,
},
kind: "types",
isPlugin,
Expand Down Expand Up @@ -547,11 +548,11 @@ const universalFiles = [...nonPluginUniversalFiles, ...pluginFiles].flatMap(
...[
{
format: "esm",
file: `${outputBaseName}${extensions.esm}`,
file: `${PACKAGE_NAME}/${outputBaseName}${extensions.esm}`,
},
{
format: "umd",
file: `${outputBaseName}${extensions.umd}`,
file: `${PACKAGE_NAME}/${outputBaseName}${extensions.umd}`,
umdVariableName,
},
].map((output) => ({
Expand Down Expand Up @@ -659,7 +660,7 @@ const nodejsFiles = [
input,
output: {
format,
file: `${outputBaseName}${extensions[format]}`,
file: `${PACKAGE_NAME}/${outputBaseName}${extensions[format]}`,
},
platform: "node",
buildOptions,
Expand Down Expand Up @@ -688,7 +689,7 @@ const metaFiles = [
},
].map((file) => ({
...file,
output: { file: file.input, ...file.output },
output: { file: `${PACKAGE_NAME}/${file.input}`, ...file.output },
kind: "meta",
}));

Expand Down