uuidjs/uuid

import uuidV4 from 'uuid/v4' breaks in the browser, but not in @testing-library/react

josephmarkus opened this issue · 3 comments

Describe the bug

I have a component that uses import uuidV4 from 'uuid/v4'; - this breaks in the browser with

Uncaught RangeError: Maximum call stack size exceeded
    at Object.exports.deprecate

However, when I import the component that relies on this import, it runs fine. I can console log uuid output without issues.

How to reproduce

  1. Use "uuid": "^7.0.3" in your package.json
  2. Use unsupported syntax import uuidV4 from 'uuid/v4'; in your file
  3. Preview the page. In my case it's Gatsby JS + React

Expected behavior

I would expect the module import to break in both - the browser and Node environment

Runtime

  • OS: macOS
  • Runtime: Chrome and Node.js
  • Runtime Version: 14.17.0

Additional information

I would like to add a test that essentially captures this runtime error in test just like it breaks on the page, so that I could programatically catch the issue when I update the library in the future

Deep imports are no longer supported.

Please upgrade to the latest version of this library and use the documented way to import it: https://github.com/uuidjs/uuid#quickstart

@ctavan I know it's no longer supported in the latest version. My question was how do I test this when uuid in the browser and node behave differently?

Running into this as well.
@ctavan It makes sense that deep imports are no longer supported, but the currently used deprecate warning mechanism is broken and leads to infinite recursion as @josephmarkus have mentioned.