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

Webpack >= 5 no longer include polyfills for node.js core modules by default. #10

Open
jamacku opened this issue May 24, 2022 · 4 comments

Comments

@jamacku
Copy link
Contributor

jamacku commented May 24, 2022

Module not found: Error: Can't resolve 'stream' in '/home/runner/work/ciboard/ciboard/node_modules/sax/lib'

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: { "stream": require.resolve("stream-browserify") }'
	- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "stream": false }

Possible solution: Install polyfills and resolve them or turn them off using new Webpack API

Blocks: #6

@mgrabovsky
Copy link
Collaborator

mgrabovsky commented Jun 14, 2022

Looking closer at this: Specifying/overriding resolves requires changing the webpack config which is not possible with vanilla Create React App unless we eject. An alternative is to go the react-rewire-app way, which sort of monkey-patches the config at build time.

@mgrabovsky
Copy link
Collaborator

@Andrei-Stepanov Do you have a preferred way of solving this (eject vs. react-rewire-app)? We should fix this one day so that xml2js keeps working correctly.

@Andrei-Stepanov
Copy link
Contributor

Hm, is only us who bumps into this? maybe try look for more solutions? I am against for 100% for eject. This is development code. I propose to google other solutions or practices that allows publish code on github.

@mgrabovsky
Copy link
Collaborator

mgrabovsky commented Jun 30, 2022

Well, react-rewire-app seems to be a popular option for those who don't want to eject.

Another option that comes to mind is migrating to a different XML parsing library. The one we use was last updated 6 years ago, so the migration would be a prudent decision either way.

A quick search turns up two fair-looking candidates: htmlparser2 (~22 million weekly downloads, written in TypeScript) and fast-xml-parser (~4 million, JS but with TS declarations built in).

mgrabovsky added a commit that referenced this issue Jan 17, 2023
The `xml2js-parser` package hasn't been updated in 6 years, so it's time
to move to a more up-to-date alternative. `fast-xml-parser` looks fairly
decent, has TypeScript declarations built-in and will allow us to debug
and iterate faster on changes in the future.

Closes #10
mgrabovsky added a commit that referenced this issue Jan 17, 2023
The `xml2js-parser` package hasn't been updated in 6 years, so it's time
to move to a more up-to-date alternative. `fast-xml-parser` looks fairly
decent, has TypeScript declarations built-in and will allow us to debug
and iterate faster on changes in the future.

Closes #10
mgrabovsky added a commit that referenced this issue Mar 1, 2023
The `xml2js-parser` package hasn't been updated in 6 years, so it's time
to move to a more up-to-date alternative. `fast-xml-parser` looks fairly
decent, has TypeScript declarations built-in and will allow us to debug
and iterate faster on changes in the future.

Closes #10
mgrabovsky added a commit that referenced this issue Jul 28, 2023
The `xml2js-parser` package hasn't been updated in 6 years, so it's time
to move to a more up-to-date alternative. `fast-xml-parser` looks fairly
decent, has TypeScript declarations built-in and will allow us to debug
and iterate faster on changes in the future.

Closes #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants