jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Missing dependencies when using yarn 2

Open boerngen-schmidt opened this issue 4 years ago • 1 comments

Describe the bug It seems that the @jsonforms/core package requires tslib, lodash and prop-types as installed dependency. I could also recreate this issue with the jsonforms-react-seed, so I'll be using it for the bug report as base.

Failed to compile.

./.yarn/cache/@jsonforms-core-npm-2.5.0-a001c716d3-55644c8c1a.zip/node_modules/@jsonforms/core/lib/generators/uischema.js
Module not found: @jsonforms/core tried to access tslib, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

./.yarn/$$virtual/@jsonforms-material-renderers-virtual-d60f75eb17/0/cache/@jsonforms-material-renderers-npm-2.5.0-452d6c3961-a9d07b93bb.zip/node_modules/@jsonforms/material-renderers/lib/complex/CombinatorProperties.js
Module not found: @jsonforms/material-renderers tried to access lodash, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

./.yarn/$$virtual/@material-ui-pickers-virtual-c2c0146eff/0/cache/@material-ui-pickers-npm-3.3.10-f5e6b01c73-295219264b.zip/node_modules/@material-ui/pickers/esm/Calendar-11ae61f6.js
Module not found: @material-ui/pickers tried to access prop-types (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

To Reproduce

  1. git clone https://github.com/eclipsesource/jsonforms-react-seed.git && cd jsonforms-react-seed
  2. use yarn 2 aka npm install -g yarn && yarn set version berry && yarn install
  3. yarn start

To Fix issue

  1. yarn add tslib lodash prop-types
  2. yarn start

Expected behavior Expected yarn 2 to install all necessary dependencies to run the app

Additional context After manually adding I was able to run yarn start without a compile error, but then this happend

TypeScript error in C:/Development/git/jsonforms-react-seed/src/App.tsx(8,20):
Cannot find module './schema.json' or its corresponding type declarations.  TS2307

     6 | import logo from './logo.svg';
     7 | import './App.css';
  >  8 | import schema from './schema.json';
       |                    ^
     9 | import uischema from './uischema.json';
    10 | import {
    11 |   materialCells,

I do not know if this is a problem on my side, since I also experienced this in other apps I wrote. The error was solved by commenting the imports and use

const schema = require('./schema.json');
const uischema = require('./uischema.json');

boerngen-schmidt avatar Mar 12 '21 18:03 boerngen-schmidt

Thanks for the report. Support for yarn2 is currently not in the shortlist of our priorities, however as it becomes more popular we'll certainly take a look. If you have experience with yarn2 and solved the issues you described we would also happily accept a contribution.

sdirix avatar Mar 31 '21 10:03 sdirix

@sdirix This is not only for yarn2, but all later version that support PlugAndPlay.

The issue is not that hard to fix: declare the dependencies of the npm packages you are using in your package.json file. This should be done anyway imo to adhere to best practices in maintaining a library.

I hope bumping this issue, will help you to fix this in the next version. Thanks a lot!

Sewdn avatar Jul 28 '23 11:07 Sewdn

Hi @Sewdn , thank you for the reminder. We recently switched to pnpm with https://github.com/eclipsesource/jsonforms/pull/2148 . As we don't hoist dependencies anymore as before, we declared dependencies explicitly in this PR. Thus, I will close this issue now. If you still notice these issues from version v3.1.1-alpha.0 onwards, feel free to reopen this issue or open a new one.

lucas-koehler avatar Jul 28 '23 12:07 lucas-koehler