4lessandrodev / rich-domain

A lib to help you create a robust project based on domain driven-design (ddd) principles with typescript and zero dependencies.
https://www.npmjs.com/package/rich-domain
MIT License
122 stars 5 forks source link

BUG with next JS #10

Closed tamon-persol closed 2 years ago

tamon-persol commented 2 years ago

Describe the bug I try to use your library with nextJs but it doesn't seem to work.

To Reproduce Steps to reproduce the behavior:

  1. create a valueObject
  2. next dev
  3. See error

Screenshots

Screen Shot 2022-09-14 at 4 39 59

Lib Version Example: rich-domain v1.1.0

Additional context Add any other context about the problem here.

tamon-persol commented 2 years ago
Screen Shot 2022-09-14 at 5 30 08
4lessandrodev commented 2 years ago

Hey @tamon-persol thanks for reporting this bug.

This happens because nextJS generates a bundle on build the app and imports all libraries in a single package. To generate UUID the rich-domain lib uses cripto native in nodejs.

To fix this, the "rich-domain" library needs to expose Crypto compatible with browser. It is native to nodeJS version 14 as higher.

I will work on it.

4lessandrodev commented 2 years ago

@tamon-persol you can check the new version v1.12.0

I made this example https://github.com/4lessandrodev/fix-next-rich-domain