Skip to content

Commit 78d00eb

Browse files
committed
Override webpackbar to v7 and add notice
Temporarily add an overrides entry to package.json to force webpackbar ^7 for @docusaurus/bundler and add a postinstall script that prints a notice when @docusaurus/bundler declares webpackbar v7+, so the override can be removed. Update package.json (scripts, spelling) and package-lock.json accordingly. This is a short-term workaround for facebook/docusaurus#11923. Signed-off-by: Patrice Chalin <pchalin@gmail.com>
1 parent 1850ca6 commit 78d00eb

3 files changed

Lines changed: 70 additions & 119 deletions

File tree

package-lock.json

Lines changed: 23 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"docusaurus": "docusaurus",
3838
"fix:format": "npm run _check:format -- --write",
3939
"fix": "npm run seq -- $(npm -s run _list:fix:*)",
40+
"postinstall": "node scripts/postinstall-webpackbar-notice.mjs",
4041
"precheck:links": "npm run build",
4142
"seq": "bash -c 'for cmd in \"$@\"; do npm run $cmd || exit 1; done' - ",
4243
"serve": "npm run docus:serve",
@@ -67,8 +68,14 @@
6768
"prettier": "^3.8.3",
6869
"typescript": "~6.0.2"
6970
},
71+
"//": "TEMP overrides (webpackbar): remove after @docusaurus/* ships webpackbar ^7 — https://github.com/facebook/docusaurus/issues/11923",
72+
"overrides": {
73+
"@docusaurus/bundler": {
74+
"webpackbar": "^7.0.0"
75+
}
76+
},
7077
"private": true,
71-
"spelling": "cSpell:ignore ACMR docus HTMLTEST loglevel -",
78+
"spelling": "cSpell:ignore ACMR docus HTMLTEST loglevel webpackbar -",
7279
"prettier": {
7380
"proseWrap": "always",
7481
"singleQuote": true
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* After install: if @docusaurus/bundler declares webpackbar ^7+, print that our
3+
* temporary package.json overrides can be removed. Otherwise stay silent.
4+
* @see https://github.com/facebook/docusaurus/issues/11923
5+
*/
6+
import fs from 'node:fs';
7+
import path from 'node:path';
8+
import { fileURLToPath } from 'node:url';
9+
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
const root = path.join(__dirname, '..');
12+
const bundlerPkgPath = path.join(
13+
root,
14+
'node_modules/@docusaurus/bundler/package.json',
15+
);
16+
17+
function bundlerDeclaresWebpackbarV7Plus(range) {
18+
if (!range || typeof range !== 'string') return false;
19+
const m = range.match(/^[~^]?(\d+)/) || range.match(/>=\s*(\d+)/);
20+
return m ? Number(m[1]) >= 7 : false;
21+
}
22+
23+
let range = '';
24+
try {
25+
const pkg = JSON.parse(fs.readFileSync(bundlerPkgPath, 'utf8'));
26+
range = pkg.dependencies?.webpackbar ?? '';
27+
} catch {
28+
process.exit(0);
29+
}
30+
31+
if (!bundlerDeclaresWebpackbarV7Plus(range)) {
32+
process.exit(0);
33+
}
34+
35+
const tag = '[techdocs] Docusaurus / webpackbar';
36+
console.log(
37+
`${tag}: @docusaurus/bundler now declares webpackbar ${range}. Remove the temporary "overrides" block and the "//" comment from package.json, then run npm install.`,
38+
);
39+
console.log(' https://github.com/facebook/docusaurus/issues/11923');

0 commit comments

Comments
 (0)