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

0.79 regression: Yarn 3 berry errors with @nivo/legends dependencies (d3-scale and @nivo/colors) #1951

Closed
davidcalhoun opened this issue Mar 14, 2022 · 7 comments
Labels

Comments

@davidcalhoun
Copy link
Contributor

davidcalhoun commented Mar 14, 2022

Describe/explain the bug
Using @nivo/legends in a project with Webpack and Yarn 3 berry results in these errors in @nivo/legends:

  • ModuleNotFoundError: Module not found: Error: Can't resolve '@nivo/colors'... ... @nivo/legends tried to access @nivo/colors, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
  • ModuleNotFoundError: Module not found: Error: Can't resolve 'd3-scale'... ... @nivo/legends tried to access d3-scale, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

I'm able to compile without errors in the previous version 0.78. It looks like as of 0.79, d3-scale and @nivo/colors are now being used in the code. These two dependencies have been added to devDependencies but since they run in production they should instead be added to dependencies, which will clear up the Yarn/Webpack error. I was able to confirm this by adding a temporary Yarn packageExtensions workaround in .yarnrc.yml:

# .yarnrc.yml

...

packageExtensions:
    '@nivo/legends@*':
        dependencies:
            'd3-scale': '*'
            '@nivo/colors': '*'
...

Adding this and then rerunning yarn works as a temporary workaround.

To Reproduce
Create a new project using Yarn 3 and Webpack 5. Use a Nivo Bar chart that uses a legend and then try to compile the project. In the case above I'm using Storybook, which uses Webpack 5 under the hood.

Expected behavior
I expect Webpack to compile without errors.

Screenshots
Full error:

ModuleNotFoundError: Module not found: Error: Can't resolve 'd3-scale' in '/Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/dist'
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/Compilation.js:2014:28
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:791:13
    at eval (eval at create (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:265:22
    at eval (eval at create (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:427:22
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:111:11
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:663:25
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:848:8
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:968:5
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/cache/neo-async-npm-2.6.2-75d6902586-deac9f8d00.zip/node_modules/neo-async/async.js:6883:13
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:951:45
    at finishWithoutResolve (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/enhanced-resolve-npm-5.9.1-9fd94589cf-d5adf8fa8b.zip/node_modules/enhanced-resolve/lib/Resolver.js:312:11)
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/cache/enhanced-resolve-npm-5.9.1-9fd94589cf-d5adf8fa8b.zip/node_modules/enhanced-resolve/lib/Resolver.js:386:15
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/cache/enhanced-resolve-npm-5.9.1-9fd94589cf-d5adf8fa8b.zip/node_modules/enhanced-resolve/lib/Resolver.js:435:5
    at eval (eval at create (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
resolve 'd3-scale' in '/Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/dist'
  Parsed request is a module
  using description file: /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      request is not managed by the pnpapi
        @nivo/legends tried to access d3-scale, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
        Required package: d3-scale
        Required by: @nivo/legends@virtual:888f7fcac72d11930aeb4fe441c94c746f1941a2f41ba75aa661170163646568d6fa45f4cb04a9df4aa9d63836d2b072cd115b0c7a3ed170008cb5a67e712807#npm:0.79.1 (via /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/dist/)
ModuleNotFoundError: Module not found: Error: Can't resolve '@nivo/colors' in '/Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/dist'
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/Compilation.js:2014:28
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:791:13
    at eval (eval at create (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:265:22
    at eval (eval at create (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:427:22
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:111:11
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:663:25
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:848:8
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:968:5
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/cache/neo-async-npm-2.6.2-75d6902586-deac9f8d00.zip/node_modules/neo-async/async.js:6883:13
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/webpack-virtual-083a0157ef/0/cache/webpack-npm-5.69.1-e85947ca9d-490a6e9e4c.zip/node_modules/webpack/lib/NormalModuleFactory.js:951:45
    at finishWithoutResolve (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/enhanced-resolve-npm-5.9.1-9fd94589cf-d5adf8fa8b.zip/node_modules/enhanced-resolve/lib/Resolver.js:312:11)
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/cache/enhanced-resolve-npm-5.9.1-9fd94589cf-d5adf8fa8b.zip/node_modules/enhanced-resolve/lib/Resolver.js:386:15
    at /Users/dcalhoun/dev/[REDACTED]/.yarn/cache/enhanced-resolve-npm-5.9.1-9fd94589cf-d5adf8fa8b.zip/node_modules/enhanced-resolve/lib/Resolver.js:435:5
    at eval (eval at create (/Users/dcalhoun/dev/[REDACTED]/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
resolve '@nivo/colors' in '/Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/dist'
  Parsed request is a module
  using description file: /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      request is not managed by the pnpapi
        @nivo/legends tried to access @nivo/colors, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
        Required package: @nivo/colors
        Required by: @nivo/legends@virtual:888f7fcac72d11930aeb4fe441c94c746f1941a2f41ba75aa661170163646568d6fa45f4cb04a9df4aa9d63836d2b072cd115b0c7a3ed170008cb5a67e712807#npm:0.79.1 (via /Users/dcalhoun/dev/[REDACTED]/.yarn/__virtual__/@nivo-legends-virtual-a3300eb7f3/0/cache/@nivo-legends-npm-0.79.1-dd1c63aa09-1f4bb8da28.zip/node_modules/@nivo/legends/dist/)

Desktop (please complete the following information):

  • OS: macOS 11.6
  • Browser N/A
  • Version N/A
@davidcalhoun
Copy link
Contributor Author

This is related to #1941 but with added details - I'm ok if you want to close this in favor of that ticket.

@stale
Copy link

stale bot commented Jun 13, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Jun 13, 2022
@davidcalhoun
Copy link
Contributor Author

Bump

@stale
Copy link

stale bot commented Sep 20, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Sep 20, 2022
@stale
Copy link

stale bot commented Sep 27, 2022

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@stale stale bot closed this as completed Sep 27, 2022
@mihiretkiflu
Copy link

bump

@plouc
Copy link
Owner

plouc commented Apr 28, 2023

I'm trying to address this issue in #2313.

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

No branches or pull requests

3 participants