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

Fix: process is undefined error #178

Merged
merged 12 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tasty-lions-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'docusaurus-theme-redoc': patch
---

Add back node-polyfill to fix client errors
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "yarn lint --fix",
"release": "yarn build:packages && changeset publish --no-git-tag",
"start": "yarn build && yarn workspace redocusaurus-website run start",
"serve": "yarn workspace redocusaurus-website run serve",
"start": "yarn build:packages && yarn workspace redocusaurus-website run start",
"test": "echo \"Error: no test specified\" && exit 1",
"version": "changeset version && yarn install --no-immutable && sh scripts/combine-changelog.sh",
"prepare": "husky install"
Expand All @@ -36,11 +37,11 @@
},
"homepage": "https://github.com/rohit-gohri/redocusaurus#readme",
"devDependencies": {
"@changesets/changelog-github": "^0.4.3",
"@changesets/cli": "^2.21.1",
"@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"concurrently": "^7.0.0",
"concurrently": "^7.1.0",
"eslint": "^8.11.0",
"eslint-config-airbnb-typescript": "^16.1.1",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -52,7 +53,7 @@
"husky": "^7.0.4",
"lint-staged": "^12.3.5",
"prettier": "2.5.1",
"typescript": "^4.6.2"
"typescript": "^4.6.4"
},
"engines": {
"node": ">=14"
Expand Down
2 changes: 0 additions & 2 deletions packages/docusaurus-plugin-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"src"
],
"keywords": [
"redoc",
"api-doc",
"docusaurus",
"docusaurus-plugin"
],
Expand Down
17 changes: 7 additions & 10 deletions packages/docusaurus-theme-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"url": "git+https://github.com/rohit-gohri/redocusaurus.git"
},
"keywords": [
"redoc",
"api-doc",
"docusaurus",
"docusaurus-theme"
],
Expand All @@ -39,21 +37,20 @@
"clsx": "^1.1.1",
"copyfiles": "^2.4.1",
"lodash": "^4.17.21",
"mobx": "^6.3.13",
"mobx": "^6.5.0",
"redoc": "2.0.0-rc.69",
"styled-components": "^5.3.3",
"to-arraybuffer": "^1.0.1"
"styled-components": "^5.3.5"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0-beta.20",
"@docusaurus/theme-classic": "^2.0.0-beta.20",
"@types/lodash": "^4.14.179",
"@types/react-dom": "^17.0.13",
"@types/lodash": "^4.14.182",
"@types/react-dom": "^17.0.17",
"@types/react-router-dom": "^5.3.3",
"@types/rtlcss": "^3.1.2",
"@types/styled-components": "^5.1.24",
"@types/rtlcss": "^3.1.4",
"@types/styled-components": "^5.1.25",
"nodemon": "^2.0.15",
"typescript": "^4.6.2"
"typescript": "^4.6.4"
},
"engines": {
"node": ">=14"
Expand Down
15 changes: 6 additions & 9 deletions packages/docusaurus-theme-redoc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@ export default function redocTheme(
name: 'docusaurus-theme-redoc',
configureWebpack(_config, isServer) {
return {
resolve: {
fallback: {
tty: false,
},
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^tty$/,
require.resolve('./tty'),
),
new webpack.DefinePlugin({
'process.versions.node': JSON.stringify(
process.versions.node || '0.0.0',
),
'process.platform': JSON.stringify(''),
'process.env': JSON.stringify({}),
}),
new webpack.NormalModuleReplacementPlugin(
/^redoc$/,
require.resolve('redoc/bundles/redoc.browser.lib'),
),
...(isServer
? [
new webpack.NormalModuleReplacementPlugin(
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme-redoc/src/tty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isatty = () => false;
118 changes: 67 additions & 51 deletions packages/redocusaurus/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Redocusaurus](https://github.com/rohit-gohri/redocusaurus)
# [Redocusaurus](https://redocusaurus.vercel.app/)

![npm](https://img.shields.io/npm/v/redocusaurus?style=flat-square)

Expand All @@ -8,69 +8,85 @@

1. Install redocusaurus:

```sh
npm i --save redocusaurus
```
```sh
npm i --save redocusaurus
# OR
yarn add redocusaurus
```

1. Add it as a preset to your docusaurus config and pass options:

- Pass it a path to a local OpenAPI YAML file

```js
// docusaurus.config.js

module.exports = {
// ...
presets: [
[
'redocusaurus',
{
specs: [
{
spec: 'openapi.yaml',
},
],
},
],
],
// ...
};
```

- Pass it a OpenAPI spec URL

```js
// docusaurus.config.js

module.exports = {
// ...
presets: [
[
'redocusaurus',
{
specs: [
{
spec: 'https://redocly.github.io/redoc/openapi.yaml',
},
],
},
],
],
// ...
};
```

The API Doc will be available by default at `/api/` path. To customize it see [full plugin options](../docusaurus-plugin-redoc/Readme.md).
```js
// docusaurus.config.js

module.exports = {
// ...
presets: [
[
'redocusaurus',
{
// Plugin Options for loading OpenAPI files
specs: [
{
spec: 'openapi/openapi.yaml',
route: '/api/',
},
],
// Theme Options for modifying how redoc renders them
theme: {
// Change with your site colors
primaryColor: '#1890ff',
},
},
],
],
// ...
};
```

- OR Pass it a OpenAPI spec URL

```js
// docusaurus.config.js

module.exports = {
// ...
presets: [
[
'redocusaurus',
{
// Plugin Options for loading OpenAPI files
specs: [
{
spec: 'https://redocly.github.io/redoc/openapi.yaml',
route: '/api/',
},
],
// Theme Options for modifying how redoc renders them
theme: {
// Change with your site colors
primaryColor: '#1890ff',
},
},
],
],
// ...
};
```

The API Doc will be available at the route specified (`/api/` in the example above). To customize it see [full plugin options](https://redocusaurus.vercel.app/docs/getting-started/plugin-options).

### Options

#### specs

Pass it an array of plugin options, see [docusaurus-plugin-redoc](../docusaurus-plugin-redoc/Readme.md) for individual option details.
Pass it an array of plugin options, see [docusaurus-plugin-redoc](https://redocusaurus.vercel.app/docs/getting-started/plugin-options) for individual option details.

#### theme

Pass options to customize the theme, see [docusaurus-theme-redoc](../docusaurus-theme-redoc/Readme.md) for individual option details.
Pass options to customize the theme, see [docusaurus-theme-redoc](https://redocusaurus.vercel.app/docs/getting-started/theme-options) for individual option details.

## Docs

Expand Down
4 changes: 3 additions & 1 deletion packages/redocusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"keywords": [
"redoc",
"openapi",
"documentations",
"api",
"swagger",
"documentation",
"api-doc",
"docusaurus",
"docusaurus-preset"
Expand Down
4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"redocusaurus": "^1.0.3"
},
"devDependencies": {
"@percy/cli": "^1.0.0-beta.76",
"@types/react": "^17.0.39"
"@percy/cli": "^1.1.4",
"@types/react": "^17.0.45"
},
"browserslist": {
"production": [
Expand Down
Loading