Code Monkey home page Code Monkey logo

Comments (8)

chris-pardy avatar chris-pardy commented on May 24, 2024 1

@MohHamoud this makes sense since we transform the source from modules to common / require. As part of that babel is doing a default import transformation. Then the webpack resolution is giving us the wrong version of the hash-it library.

from json-rules-engine.

chris-pardy avatar chris-pardy commented on May 24, 2024

@dcowan-e-courier can you check which version of hash-it you have installed?

from json-rules-engine.

siawyoung avatar siawyoung commented on May 24, 2024

I'm seeing this error too. If it helps, I have the same code running successfully in a Node environment, but running it in a browser environment (Chrome) produces the above error. The exact version of hash-it on both environments:

hash-it@^6.0.0:
  version "6.0.0"
  resolved "https://registry.yarnpkg.com/hash-it/-/hash-it-6.0.0.tgz#188df5a8ca2f8e036690e35f2ef88bd9417ff334"
  integrity sha512-KHzmSFx1KwyMPw0kXeeUD752q/Kfbzhy6dAZrjXV9kAIXGqzGvv8vhkUqj+2MGZldTo0IBpw6v7iWE7uxsvH0w==

from json-rules-engine.

siawyoung avatar siawyoung commented on May 24, 2024

@dcowan-e-courier if it helps, I tried running this in a fresh NextJS environment (using create-next-app) instead of create-react-app. That works. My guess is it has something to do with the Webpack bundling in create-react-app and how it messes up default exports. I don't have time to explore this further but hopefully it unblocks you!

from json-rules-engine.

chris-pardy avatar chris-pardy commented on May 24, 2024

@siawyoung @dcowan-e-courier this does seem to be related to the export mapping on the hash-it package and how something like webpack is resolving that.

from json-rules-engine.

MohHamoud avatar MohHamoud commented on May 24, 2024

I am having the same error in an existing project, I reproduced the issue by creating a project using create-react-app as @siawyoung mentioned, is there a fast way to fix it?
I understand that create-next-app creates a next.js application, which I don't prefer doing.

from json-rules-engine.

chris-pardy avatar chris-pardy commented on May 24, 2024

@MohHamoud I haven't reproduced this issue since it's more related to webpack than json-rules-engine but...

The issue is likely that the webpack version that create-react-app is using doesn't understand the export mapping in hash-it's package.json.

Option 1: Downgrade hash-it - depending on your package manager of choice you may be able to force the resolution of hash-it to an older version that doesn't have the export mapping.
Option 2: Upgrade webpack. I'm not sure which version of webpack create-react-app uses but the export mapping is a fairly new package.json feature so we older webpack versions may not support it. This will likely requiring ejecting.

Overall I'd probably go the Option 2 route. specifically because create-react-app is no longer supported by the react team. If you don't wish to go with one of the various react-ecosystem setups then you're best bet is likely a roll-your-own approach.

from json-rules-engine.

MohHamoud avatar MohHamoud commented on May 24, 2024

@chris-pardy I cloned the project, then copied the src files to my project and "yarn add"-ed the required dependencies (including hash-it)
it worked fine, without specifying the version of the hash-it nor the webpack

from json-rules-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.