Closed
Description
Describe the Bug
Compiling a react app with this library as dependency results in a compilation error.
Steps to Reproduce
- Create a react app using the
create-react-app
tooling - Add
cloudevents
as dependency - Compile project
Compiling the project results in the following error message:
ERROR in ./node_modules/cloudevents/dist/transport/http/index.js 18:31-46
Module not found: Error: Can't resolve 'http' in '/home/[...]/node_modules/cloudevents/dist/transport/http'
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: { "http": require.resolve("stream-http") }'
- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "http": false }
ERROR in ./node_modules/cloudevents/dist/transport/http/index.js 20:32-48
Module not found: Error: Can't resolve 'https' in '/home/[...]/node_modules/cloudevents/dist/transport/http'
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: { "https": require.resolve("https-browserify") }'
- install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "https": false }
Expected Behavior
It should be possible to compile the project including this library as dependency in a browser project without the need for additional webpack configuration.
Additional Context
I know that there is some kind of workaround by configuring webpack, but the create-react-app
tool does not support modifying the webpack configuration and the maintainers discourage from doing this: facebook/create-react-app#11756 (comment)