stoplightio / json-schema-viewer

A JSON Schema viewer React component
Apache License 2.0
175 stars 37 forks source link

There's an error about polyfills when starting a project (create-react-app@5) #252

Open starikovs opened 8 months ago

starikovs commented 8 months ago

I create a new project with npx create-react-app my-app, then I install npm i @stoplight/json-schema-viewer, and use it in the App.js providing a valid json schema:

import { JsonSchemaViewer } from "@stoplight/json-schema-viewer";

<JsonSchemaViewer
  name="Todos Model"
  schema={schema}
  expanded={true}
  hideTopBar={false}
  emptyText="No schema defined"
  defaultExpandedDepth={0}
/>; 

When I run npm start to start the project, I get such errors:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
    - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "buffer": false }

Maybe I'm doing something wrong, but maybe there's a bug.

Context

Cannot use the library.

Current Behavior

An error about polyfills when npm start.

Expected Behavior

I guess there shouldn't be an error when starting a project.

Possible Workaround/Solution

Steps to Reproduce

In the description.

Environment