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

Updating 4.13.0 -> 4.13.1 causes "Module not found: Error: Can't resolve 'util'" when building #8136

Closed
AuroraLS3 opened this issue Aug 2, 2022 · 7 comments
Assignees

Comments

@AuroraLS3
Copy link

AuroraLS3 commented Aug 2, 2022

Q&A (please complete the following information)

  • OS: ubuntu (Github actions)
  • Browser: none
  • Version: -
  • Method of installation: npm (yarn)
  • Swagger-UI version: 4.13.1
  • Swagger/OpenAPI version: -

Content & configuration

Swagger-UI configuration options:

        SwaggerUI({
            dom_id: "#swagger-ui",
            url: baseAddress + "/docs/swagger.json"
        });

Describe the bug you're encountering

Build is failing if swagger is updated by dependabot plan-player-analytics/Plan#2527 (builds using 4.13.0 successful)

yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve 'util' in '/home/runner/work/Plan/Plan/Plan/react/dashboard/node_modules/swagger-ui/dist'
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: { "util": require.resolve("util/") }'
	- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "util": false }

error Command failed with exit code 1.

To reproduce...

Steps to reproduce the behavior: (speculative)

  1. Create a react app
  2. Add swagger 4.13.1 as dependency
  3. Build
  4. See error

Expected behavior

No errors during npm build

Additional context or thoughts

@char0n
Copy link
Member

char0n commented Aug 2, 2022

Additional problem with 4.13.1 is that logical nullish assignment (??=) is no longer transformed by babel which disqualifies testing SwaggerUI in Node.js@14.

@char0n
Copy link
Member

char0n commented Aug 2, 2022

Fixes provided in #8137

char0n added a commit that referenced this issue Aug 2, 2022
List of regressions fixed in this commit:

1. need to polyfill util module
2. always transform logical nullish assignment with babel 

Refs #8136
@char0n
Copy link
Member

char0n commented Aug 2, 2022

Regression with util fixed by not installing util in our dependency tree

Regression with logical nullish assignment fixed by always using transformation provided by @babel/plugin-proposal-logical-assignment-operators as part of running babel preset env tranformations.

@char0n char0n closed this as completed Aug 2, 2022
@char0n
Copy link
Member

char0n commented Aug 2, 2022

@AuroraLS3
Copy link
Author

Thank you for the quick fix - I'll report back tomorrow when dependabot updates again.

@char0n
Copy link
Member

char0n commented Aug 3, 2022

@AuroraLS3 your CI is green on 4.13.2 - plan-player-analytics/Plan#2529

@AuroraLS3
Copy link
Author

Yep indeed it is, thanks!

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

No branches or pull requests

2 participants