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

fix(build): undeclared dependencies #1391

Merged
merged 1 commit into from Feb 3, 2023

Conversation

thekip
Copy link
Collaborator

@thekip thekip commented Feb 1, 2023

Description

This is a partial fix for undeclared dependencies. #1385

  • @messageformat/parser is used in packages/cli/src/api/formats/po-gettext.ts but was not declared for @lingui/cli
  • @babel/types used in macro but was not declared.

But:

yarnPath: .yarn/releases/yarn-3.3.1.cjs
packageExtensions:
  "@lingui/cli@*":
    dependencies:
      "@messageformat/parser": "*"
  "@lingui/macro@*":
    dependencies:
      "@babel/types": "*"
  "@lingui/conf@*":
    dependencies:
      "@types/node": "*"
      typescript: "*"
  "@lingui/loader@*":
    dependencies:
      "@babel/core": "*"
      typescript: "*"

Yarn complaining about few other dependencies as well. These are peer dependencies of a transitive dependencies and i didn't find an explainer what should we do in this case.

Take for example @lingui/loader

  "@lingui/loader@*":
    dependencies:
      "@babel/core": "*"
      typescript: "*"

The package actually not depending on typescript nor @babel/core directly. But it has @lingui/conf and @lingui/cli as direct deps. And @lingui/cli has a peer dep for @babel/core which is not directly satisfied in the @lingui/loader package. The same with typescript.

@lingui/loader -> @lingui/cli -> @babel/core (peer)
@lingui/loader -> @lingui/conf -> cosmiconfig-typescript-loader -> typescript (peer)

Generally speaking, i don't know how to fix it properly. Should we replicate all this peer dependencies in parent package?
I would be very grateful if some one point me to article with explanation.

Also thinking how to automate testing for such issues.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@vercel
Copy link

vercel bot commented Feb 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 1, 2023 at 3:50PM (UTC)

@github-actions
Copy link

github-actions bot commented Feb 1, 2023

size-limit report 📦

Path Size
./packages/core/build/esm/index.js 2.89 KB (0%)
./packages/detect-locale/build/esm/index.js 804 B (0%)
./packages/react/build/esm/index.js 2.61 KB (0%)
./packages/remote-loader/build/esm/index.js 7.36 KB (0%)

@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Base: 82.60% // Head: 82.66% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (b1b85f7) compared to base (ad9b735).
Patch coverage: 90.23% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1391      +/-   ##
==========================================
+ Coverage   82.60%   82.66%   +0.05%     
==========================================
  Files          56       66      +10     
  Lines        1799     1759      -40     
  Branches      506      487      -19     
==========================================
- Hits         1486     1454      -32     
+ Misses        183      177       -6     
+ Partials      130      128       -2     
Impacted Files Coverage Δ
packages/cli/src/api/formats/index.ts 60.00% <ø> (ø)
packages/conf/src/index.ts 85.13% <ø> (-0.95%) ⬇️
packages/core/src/formats.ts 84.37% <ø> (ø)
packages/core/src/index.ts 100.00% <ø> (ø)
packages/macro/src/utils.ts 100.00% <ø> (ø)
packages/react/src/Trans.tsx 80.64% <ø> (ø)
packages/remote-loader/src/index.ts 66.66% <ø> (ø)
packages/remote-loader/src/browserCompiler.ts 40.00% <40.00%> (-24.87%) ⬇️
packages/cli/src/api/detect.ts 57.89% <66.66%> (-6.82%) ⬇️
packages/core/src/context.ts 80.00% <77.77%> (+0.37%) ⬆️
... and 24 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@thekip
Copy link
Collaborator Author

thekip commented Feb 1, 2023

@andrii-bodnar
Copy link
Contributor

@thekip so, according to the article we just need to declare @babel/core as a peer dependency in the @lingui/loader and so on?

@thekip
Copy link
Collaborator Author

thekip commented Feb 1, 2023

Yes, we need to hoist all peerDeps of direct deps. I will do that in this PR

@thekip
Copy link
Collaborator Author

thekip commented Feb 3, 2023

Well, let's merge these evident changes for now, because the problem with peer deps is not that simple as it looks like.

The solution with hoisting peer deps to the host package proposed by the article fills so unnatural. We should keep track of all peer dependencies all the way up and down. If the @lingui/conf uses cosmiconfig-typescript-loader which declare few peer deps, and we use @lingui/conf in almost all our packages so this peer deps should be copied and pasted to all package.json files in the lib.

It not only brings unnecessary bloat to the package.json files, but also extremely unmaintainable. It's absolutely not obvious why one package declaring what peer deps. You need to manually scan all direct dependencies used. And when some of the child packages add something new, we again need to recheck the whole package graph.

To be honest, I've never seen anyone do that.

@andrii-bodnar andrii-bodnar linked an issue Feb 3, 2023 that may be closed by this pull request
@andrii-bodnar andrii-bodnar merged commit f390ca4 into lingui:main Feb 3, 2023
@thekip thekip deleted the fix/undeclared-dependecies branch February 3, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undeclared packages not being resolved (Yarn PNP)
3 participants