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

Use declared lodash dependencies. Resolve build failures for dependen… #1366

Merged
merged 3 commits into from Jul 25, 2019

Conversation

@burkedavison
Copy link
Contributor

burkedavison commented Jul 24, 2019

…t projects using Yarn PnP.

Reasons for making this change

Dependent projects using react-jsonschema-form and Yarn PnP fail to build with the following exception:

Message:
    C:/Users/<user>/AppData/Local/Yarn/Cache/v4/npm-react-jsonschema-form-1.7.0-c2779886c56c4bab25d54e2dec76d24b384d2d73/node_modules/react-jsonschema
-form/lib/components/Form.js
Module not found: Error: Package "react-jsonschema-form@1.7.0" (via "C:\Users\<user>\AppData\Local\Yarn\Cache\v4\npm-react-jsonschema-form-1.7.0-c2779
886c56c4bab25d54e2dec76d24b384d2d73\node_modules\react-jsonschema-form\lib\components\Form.js") is trying to require the package "lodash" (via "lodash
/get") without it being listed in its dependencies (react, @babel/runtime-corejs2, ajv, core-js, lodash.get, lodash.pick, lodash.topath, prop-types, r
eact-is, react-lifecycles-compat, shortid, react-jsonschema-form)
 @ C:/Users/<user>/AppData/Local/Yarn/Cache/v4/npm-react-jsonschema-form-1.7.0-c2779886c56c4bab25d54e2dec76d24b384d2d73/node_modules/react-jsonschema-
form/lib/components/Form.js 41:35-56
 @ C:/Users/<user>/AppData/Local/Yarn/Cache/v4/npm-react-jsonschema-form-1.7.0-c2779886c56c4bab25d54e2dec76d24b384d2d73/node_modules/react-jsonschema-
form/lib/index.js
 @ C:/<path>/src/components/layouts/SimpleForm.tsx
 @ C:/<path>/src/App.tsx
 @ C:/<path>/src/index.tsx
C:/Users/<user>/AppData/Local/Yarn/Cache/v4/npm-react-jsonschema-form-1.7.0-c2779886c56c4bab25d54e2dec76d24b384d2d73/node_modules/react-jsonschema-for
m/lib/components/Form.js
Module not found: Error: Package "react-jsonschema-form@1.7.0" (via "C:\Users\<user>\AppData\Local\Yarn\Cache\v4\npm-react-jsonschema-form-1.7.0-c2779
886c56c4bab25d54e2dec76d24b384d2d73\node_modules\react-jsonschema-form\lib\components\Form.js") is trying to require the package "lodash" (via "lodash
/pick") without it being listed in its dependencies (react, @babel/runtime-corejs2, ajv, core-js, lodash.get, lodash.pick, lodash.topath, prop-types,
react-is, react-lifecycles-compat, shortid, react-jsonschema-form)
 @ C:/Users/<user>/AppData/Local/Yarn/Cache/v4/npm-react-jsonschema-form-1.7.0-c2779886c56c4bab25d54e2dec76d24b384d2d73/node_modules/react-jsonschema-
form/lib/components/Form.js 39:36-58
 @ C:/Users/<user>/AppData/Local/Yarn/Cache/v4/npm-react-jsonschema-form-1.7.0-c2779886c56c4bab25d54e2dec76d24b384d2d73/node_modules/react-jsonschema-
form/lib/index.js
 @ C:/<dependent project path>/src/components/layouts/SimpleForm.tsx
 @ C:/<dependent project path>/src/App.tsx
 @ C:/<dependent project path>/src/index.tsx
Details:
    domain: [object Object]
    domainThrown: true

The important parts of this are:

[...]/react-jsonschema-form/lib/components/Form.js
Module not found: Error: Package "react-jsonschema-form@1.7.0" (via "[...]\react-jsonschema-form\lib\components\Form.js") is trying to require the package "lodash" (via "lodash
/pick") without it being listed in its dependencies ([...], lodash.get, lodash.pick, [...])

Documentation on troubleshooting this error message from Yarn PnP is provided here:
https://yarnpkg.com/en/docs/pnp/troubleshooting#toc-is-trying-to-require-without-it-being-listed-in-its-dependencies

Ultimately, the situation boils down to this:
NPM and Yarn w/o PnP are forgiving, and can resolve packages if they are placed as dependencies by this project's dependencies (not by this project itself!). This is what is happening today. The existing lodash/get and lodash/pick dependencies used in Form.js are not declared in package.json.

@arcanis

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature
…t projects using Yarn PnP.
@burkedavison

This comment has been minimized.

Copy link
Contributor Author

burkedavison commented Jul 24, 2019

Test is failing at Form_test.js "unused form values should be omitted".
This test verifies correct behavior of a function using lodash.pick.

Test passes if lodash is added as a dependency to the project and lodash/pick is used in the import in Form.js

Test fails if lodash.pick is used as the dependency, and lodash.pick is used in the import.

@epicfaace

This comment has been minimized.

Copy link
Member

epicfaace commented Jul 25, 2019

@burkedavison thanks for the PR -- not sure why the lodash.pick approach is failing, but I believe you should be able to do the solution you mentioned (installing lodash and using lodash/pick) and it shouldn't adversely affect the bundle size.

burke davison added 2 commits Jul 25, 2019
burke davison
burke davison
@epicfaace

This comment has been minimized.

Copy link
Member

epicfaace commented Jul 25, 2019

Great, thanks!

@epicfaace epicfaace merged commit 59ab93f into rjsf-team:master Jul 25, 2019
6 checks passed
6 checks passed
Header rules - trusting-agnesi-d3347d No header rules processed
Details
Pages changed - trusting-agnesi-d3347d 1 new file uploaded
Details
Redirect rules - trusting-agnesi-d3347d No redirect rules processed
Details
Mixed content - trusting-agnesi-d3347d No mixed content detected
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
netlify/trusting-agnesi-d3347d/deploy-preview Deploy preview ready!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.