-
Notifications
You must be signed in to change notification settings - Fork 303
Description
Hi, thanks for this great package! I've run into a build failure that I think might have been introduced when node-polyfill-webpack-plugin was removed in #1081.
Description
The build fails with Module not found: Can't resolve 'path' errors originating from postman-code-generators, which uses require('path') in 13 of its code generators. The theme's configureWebpack in lib/index.js provides fallbacks for buffer and process, but not path.
This affects both the standard webpack bundler and Rspack (experimental_faster: true).
Reproduction
Minimal repro repo: https://github.com/Preston-Landers/docusaurus-openapi-docs-path-browserify-issue
git clone https://github.com/Preston-Landers/docusaurus-openapi-docs-path-browserify-issue.git
cd docusaurus-openapi-docs-path-browserify-issue
npm install
npx docusaurus gen-api-docs all
npm run build
Environment
- docusaurus-theme-openapi-docs: 4.7.1
- docusaurus-plugin-openapi-docs: 4.7.1
- @docusaurus/core: 3.9.2
- Node: 22+
- Tested on macOS, Linux, and Windows
Workaround
Adding a custom plugin with the missing fallback resolves the issue:
// docusaurus.config.js
plugins: [
function nodePathPolyfill() {
return {
name: "node-path-polyfill",
configureWebpack() {
return {
resolve: {
fallback: {
path: require.resolve("path-browserify"),
},
},
};
},
};
},
// ... other plugins
],
Suggested fix
Add path: require.resolve("path-browserify") to the resolve.fallback object in both branches of the configureWebpack method in src/index.ts, and add path-browserify as a dependency of the theme package.