Skip to content

Commit 95af630

Browse files
authored
Merge branch 'main' into npm2yarn-add-bun-default
2 parents 46687d2 + 15b0ef6 commit 95af630

File tree

60 files changed

+861
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+861
-544
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = {
6060
},
6161
reportUnusedDisableDirectives: true,
6262
plugins: [
63+
'react-compiler',
6364
'react-hooks',
6465
'header',
6566
'jest',
@@ -68,6 +69,7 @@ module.exports = {
6869
'@docusaurus',
6970
],
7071
rules: {
72+
'react-compiler/react-compiler': ERROR,
7173
'react/jsx-uses-react': OFF, // JSX runtime: automatic
7274
'react/react-in-jsx-scope': OFF, // JSX runtime: automatic
7375
'array-callback-return': WARNING,

.github/workflows/build-perf.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ jobs:
8585
# Ensure build with a cold cache does not increase too much
8686
- name: Build (cold cache)
8787
run: yarn build:website:fast
88-
timeout-minutes: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 3 || 1 }}
88+
timeout-minutes: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 3 || 2 }}
8989
env:
9090
DOCUSAURUS_SLOWER: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 'true' || 'false' }}
9191

9292
# Ensure build with a warm cache does not increase too much
9393
- name: Build (warm cache)
9494
run: yarn build:website:fast
95-
timeout-minutes: 1
95+
# Temporary: upper value for Rspack until incremental cache works better
96+
timeout-minutes: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 1 || 2 }}
9697
env:
9798
DOCUSAURUS_SLOWER: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 'true' || 'false' }}
9899

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"@types/node": "^18.16.19",
8484
"@types/prompts": "^2.4.4",
8585
"@types/react": "^18.2.15",
86-
"@types/react-dev-utils": "^9.0.11",
8786
"@types/react-test-renderer": "^18.0.0",
8887
"@types/semver": "^7.5.0",
8988
"@types/shelljs": "^0.8.12",
@@ -99,6 +98,7 @@
9998
"eslint-plugin-jest": "^27.2.3",
10099
"eslint-plugin-jsx-a11y": "^6.7.1",
101100
"eslint-plugin-react": "^7.32.2",
101+
"eslint-plugin-react-compiler": "^19.0.0-beta-40c6c23-20250301",
102102
"eslint-plugin-react-hooks": "^4.6.0",
103103
"eslint-plugin-regexp": "^1.15.0",
104104
"husky": "^8.0.3",
@@ -124,7 +124,7 @@
124124
"stylelint": "^14.16.1",
125125
"stylelint-config-prettier": "^9.0.5",
126126
"stylelint-config-standard": "^29.0.0",
127-
"typescript": "~5.7.2"
127+
"typescript": "~5.8.2"
128128
},
129129
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
130130
}

packages/create-docusaurus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
"@docusaurus/logger": "3.7.0",
2626
"@docusaurus/utils": "3.7.0",
2727
"commander": "^5.1.0",
28+
"execa": "5.1.1",
2829
"fs-extra": "^11.1.1",
2930
"lodash": "^4.17.21",
3031
"prompts": "^2.4.2",
3132
"semver": "^7.5.4",
32-
"shelljs": "^0.8.5",
3333
"supports-color": "^9.4.0",
3434
"tslib": "^2.6.0"
3535
},

packages/create-docusaurus/src/index.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import {fileURLToPath} from 'url';
1010
import path from 'path';
1111
import _ from 'lodash';
1212
import {logger} from '@docusaurus/logger';
13-
import shell from 'shelljs';
13+
import execa from 'execa';
1414
import prompts, {type Choice} from 'prompts';
1515
import supportsColor from 'supports-color';
16-
import {escapeShellArg, askPreferredLanguage} from '@docusaurus/utils';
16+
17+
// TODO remove dependency on large @docusaurus/utils
18+
// would be better to have a new smaller @docusaurus/utils-cli package
19+
import {askPreferredLanguage} from '@docusaurus/utils';
1720

1821
type LanguagesOptions = {
1922
javascript?: boolean;
@@ -70,9 +73,9 @@ function findPackageManagerFromUserAgent(): PackageManager | undefined {
7073
}
7174

7275
async function askForPackageManagerChoice(): Promise<PackageManager> {
73-
const hasYarn = shell.exec('yarn --version', {silent: true}).code === 0;
74-
const hasPnpm = shell.exec('pnpm --version', {silent: true}).code === 0;
75-
const hasBun = shell.exec('bun --version', {silent: true}).code === 0;
76+
const hasYarn = (await execa.command('yarn --version')).exitCode === 0;
77+
const hasPnpm = (await execa.command('pnpm --version')).exitCode === 0;
78+
const hasBun = (await execa.command('bun --version')).exitCode === 0;
7679

7780
if (!hasYarn && !hasPnpm && !hasBun) {
7881
return 'npm';
@@ -530,10 +533,7 @@ export default async function init(
530533

531534
if (source.type === 'git') {
532535
const gitCommand = await getGitCommand(source.strategy);
533-
const gitCloneCommand = `${gitCommand} ${escapeShellArg(
534-
source.url,
535-
)} ${escapeShellArg(dest)}`;
536-
if (shell.exec(gitCloneCommand).code !== 0) {
536+
if ((await execa(gitCommand, [source.url, dest])).exitCode !== 0) {
537537
logger.error`Cloning Git template failed!`;
538538
process.exit(1);
539539
}
@@ -583,24 +583,27 @@ export default async function init(
583583
const cdpath = path.relative('.', dest);
584584
const pkgManager = await getPackageManager(dest, cliOptions);
585585
if (!cliOptions.skipInstall) {
586-
shell.cd(dest);
586+
process.chdir(dest);
587587
logger.info`Installing dependencies with name=${pkgManager}...`;
588+
// ...
589+
588590
if (
589-
shell.exec(
590-
pkgManager === 'yarn'
591-
? 'yarn'
592-
: pkgManager === 'bun'
593-
? 'bun install'
594-
: `${pkgManager} install --color always`,
595-
{
596-
env: {
597-
...process.env,
598-
// Force coloring the output, since the command is invoked by
599-
// shelljs, which is not an interactive shell
600-
...(supportsColor.stdout ? {FORCE_COLOR: '1'} : {}),
591+
(
592+
await execa.command(
593+
pkgManager === 'yarn'
594+
? 'yarn'
595+
: pkgManager === 'bun'
596+
? 'bun install'
597+
: `${pkgManager} install --color always`,
598+
{
599+
env: {
600+
...process.env,
601+
// Force coloring the output
602+
...(supportsColor.stdout ? {FORCE_COLOR: '1'} : {}),
603+
},
601604
},
602-
},
603-
).code !== 0
605+
)
606+
).exitCode !== 0
604607
) {
605608
logger.error('Dependency installation failed.');
606609
logger.info`The site directory has already been created, and you can retry by typing:

packages/docusaurus-bundler/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"postcss": "^8.4.26",
3838
"postcss-loader": "^7.3.3",
3939
"postcss-preset-env": "^10.1.0",
40-
"react-dev-utils": "^12.0.1",
4140
"terser-webpack-plugin": "^5.3.9",
4241
"tslib": "^2.6.0",
4342
"url-loader": "^4.1.1",

packages/docusaurus-bundler/src/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {type Configuration} from 'webpack';
99
import logger from '@docusaurus/logger';
10-
import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
10+
import formatWebpackMessages from './legacy/formatWebpackMessages';
1111
import type webpack from 'webpack';
1212
import type {CurrentBundler} from '@docusaurus/types';
1313

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// TODO Legacy CRA react-dev-utils package code
9+
// This code was in CRA/react-dev-utils (deprecated in 2025)
10+
// We just copied the code as-is to remove a fat/useless dependency subtree
11+
// See https://github.com/facebook/docusaurus/pull/10956
12+
// See https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/formatWebpackMessages.js
13+
14+
/* eslint-disable */
15+
16+
const friendlySyntaxErrorLabel = 'Syntax error:';
17+
18+
function isLikelyASyntaxError(message) {
19+
return message.indexOf(friendlySyntaxErrorLabel) !== -1;
20+
}
21+
22+
// Cleans up webpack error messages.
23+
function formatMessage(message) {
24+
let lines = [];
25+
26+
if (typeof message === 'string') {
27+
lines = message.split('\n');
28+
} else if ('message' in message) {
29+
lines = message['message'].split('\n');
30+
} else if (Array.isArray(message)) {
31+
message.forEach((message) => {
32+
if ('message' in message) {
33+
lines = message['message'].split('\n');
34+
}
35+
});
36+
}
37+
38+
// Strip webpack-added headers off errors/warnings
39+
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
40+
lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
41+
42+
// Transform parsing error into syntax error
43+
// TODO: move this to our ESLint formatter?
44+
lines = lines.map((line) => {
45+
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
46+
line,
47+
);
48+
if (!parsingError) {
49+
return line;
50+
}
51+
const [, errorLine, errorColumn, errorMessage] = parsingError;
52+
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
53+
});
54+
55+
message = lines.join('\n');
56+
// Smoosh syntax errors (commonly found in CSS)
57+
message = message.replace(
58+
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
59+
`${friendlySyntaxErrorLabel} $3 ($1:$2)\n`,
60+
);
61+
// Clean up export errors
62+
message = message.replace(
63+
/^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
64+
`Attempted import error: '$1' is not exported from '$2'.`,
65+
);
66+
message = message.replace(
67+
/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
68+
`Attempted import error: '$2' does not contain a default export (imported as '$1').`,
69+
);
70+
message = message.replace(
71+
/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
72+
`Attempted import error: '$1' is not exported from '$3' (imported as '$2').`,
73+
);
74+
lines = message.split('\n');
75+
76+
// Remove leading newline
77+
if (lines.length > 2 && lines[1].trim() === '') {
78+
lines.splice(1, 1);
79+
}
80+
// Clean up file name
81+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
82+
83+
// Cleans up verbose "module not found" messages for files and packages.
84+
if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
85+
lines = [
86+
lines[0],
87+
lines[1]
88+
.replace('Error: ', '')
89+
.replace('Module not found: Cannot find file:', 'Cannot find file:'),
90+
];
91+
}
92+
93+
// Add helpful message for users trying to use Sass for the first time
94+
if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
95+
lines[1] = 'To import Sass files, you first need to install sass.\n';
96+
lines[1] +=
97+
'Run `npm install sass` or `yarn add sass` inside your workspace.';
98+
}
99+
100+
message = lines.join('\n');
101+
// Internal stacks are generally useless so we strip them... with the
102+
// exception of stacks containing `webpack:` because they're normally
103+
// from user code generated by webpack. For more information see
104+
// https://github.com/facebook/create-react-app/pull/1050
105+
message = message.replace(
106+
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
107+
'',
108+
); // at ... ...:x:y
109+
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
110+
lines = message.split('\n');
111+
112+
// Remove duplicated newlines
113+
lines = lines.filter(
114+
(line, index, arr) =>
115+
index === 0 ||
116+
line.trim() !== '' ||
117+
line.trim() !== arr[index - 1].trim(),
118+
);
119+
120+
// Reassemble the message
121+
message = lines.join('\n');
122+
return message.trim();
123+
}
124+
125+
/**
126+
* @param {import("webpack").Stats.ToJsonOutput} json.
127+
* @returns {{ errors: string[], warnings: string[] }}
128+
*/
129+
module.exports = function formatWebpackMessages(json) {
130+
const formattedErrors = json.errors.map(formatMessage);
131+
const formattedWarnings = json.warnings.map(formatMessage);
132+
const result = {errors: formattedErrors, warnings: formattedWarnings};
133+
if (result.errors.some(isLikelyASyntaxError)) {
134+
// If there are any syntax errors, show just them.
135+
result.errors = result.errors.filter(isLikelyASyntaxError);
136+
}
137+
return result;
138+
};

packages/docusaurus-cssnano-preset/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ const preset: typeof advancedBasePreset = function preset(opts) {
2626
return advancedPreset;
2727
};
2828

29+
// @ts-expect-error: TODO fix later
2930
export = preset;

packages/docusaurus-mdx-loader/src/processor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import type {WebpackCompilerName} from '@docusaurus/utils';
2222
import type {MDXFrontMatter} from './frontMatter';
2323
import type {Options} from './options';
2424
import type {AdmonitionOptions} from './remark/admonitions';
25-
26-
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
2725
import type {ProcessorOptions} from '@mdx-js/mdx';
2826

2927
// TODO as of April 2023, no way to import/re-export this ESM type easily :/

0 commit comments

Comments
 (0)