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

Issue with swagger-ui-react after update: Buffer is not defined #6869

Closed
fedemauri opened this issue Jan 27, 2021 · 4 comments
Closed

Issue with swagger-ui-react after update: Buffer is not defined #6869

fedemauri opened this issue Jan 27, 2021 · 4 comments

Comments

@fedemauri
Copy link

After the update of swagger-ui-react to 3.40.0 this error message appear in console anytime I open the page with swagger component

deep-extend.js?383b:32 Uncaught ReferenceError: Buffer is not defined
    at isSpecificValue (deep-extend.js?383b:32)
    at eval (deep-extend.js?383b:132)
    at Array.forEach (<anonymous>)
    at eval (deep-extend.js?383b:110)
    at Array.forEach (<anonymous>)
    at module.exports (deep-extend.js?383b:104)
    at Qr (swagger-ui.js?f5c3:2)
    at SwaggerUI.componentDidMount (index.js?6dc0:59)
    at commitLifeCycles (react-dom.development.js?61bb:20663)
    at commitLayoutEffects (react-dom.development.js?61bb:23426)
@mathis-m
Copy link
Contributor

mathis-m commented Jan 27, 2021

@Fedema92 Do you use webpack >= 5? I guess this is due to https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-nodejs-polyfills-removed. If so try to add the Node.Js Buffer Polyfill: webpack/changelog-v5#10 (comment)

Besides that I could not reproduce the issue. Sandboxes used: swagger-ui-react, swagger-ui-react-webpack

@fedemauri
Copy link
Author

fedemauri commented Jan 27, 2021

@Fedema92 Do you use webpack >= 5? I guess this is due to https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-nodejs-polyfills-removed. If so try to add the Node.Js Buffer Polyfill: webpack/changelog-v5#10 (comment)

Besides that I could not reproduce the issue. Sandboxes used: swagger-ui-react, swagger-ui-react-webpack

Yes, I had just updated webpack to v6. I had added the ProvidePlugin to webpack configuration and it works like a charm.
Thanks @mathis-m

@DenisLopatin
Copy link

I replaced "module": "CommonJS" with "module": "ES6" in typescript.config and it worked. I didn't use any polyfiles and used a minimal webpack build.

@AdithyaGallage
Copy link

@Fedema92 Do you use webpack >= 5? I guess this is due to https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-nodejs-polyfills-removed. If so try to add the Node.Js Buffer Polyfill: webpack/changelog-v5#10 (comment)

Besides that I could not reproduce the issue. Sandboxes used: swagger-ui-react, swagger-ui-react-webpack

This works for me, thanks @mathis-m

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

4 participants