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

chore: update nx packages #1147

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

chore: update nx packages #1147

wants to merge 12 commits into from

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Jan 7, 2025

This PR:

  • updates to nx@latest (had to do 17, then latest to get new lint modules to work). I did:
    • npx nx migrate 17
    • npx nx migrate latest
    • then just run the lint fix and manually fixed a couple lint issues
    • removed deprecated workspace-lint from CI (this validates the project config, but it's automatic now): feat(core): remove deprecated workspace-lint nrwl/nx#16212
    • added the new lint rule below
  • updates @types/node (required to fix new compilation issues)
  • updates the generators

⚠️

There is one significant change in how this repo works: we no longer automatically compute the deps for all packages, BUT we instead throw a lint error if nx calculates that you have failed to include a dep in your package.json which you import in your code.

For example, flagd uses the lru-cache package. Because we import it in our ts files, if we DON'T include it in our pacakge.json, we see this lint error (which causes the build to fail):

nx run providers-flagd:lint
      Linting "providers-flagd"...
      
      /home/todd/git/js-sdk-contrib/libs/providers/flagd/package.json
        9:3  error  The "providers-flagd" project uses the following packages, but they are missing from "peerDependencies":
          - lru-cache  @nx/dependency-checks
      
      ✖ 1 problem (1 error, 0 warnings)
        1 error and 0 warnings potentially fixable with the `--fix` option.

I think this is actually an improvement over the last behavior, since it will cause devs to think carefully about their deps.

⚠️

I have updated all the deps for all the packages appropriately according to this check. Please check the deps of your package.json.

Copy link
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that we update that!

@toddbaert
Copy link
Member Author

toddbaert commented Jan 7, 2025

Unfortunately, the nx-computed dependencies created by buildableProjectDepsInPackageJsonType no longer work (it was removed); this means we aren't properly computing deps at package time anymore. There's a new way to do this I need to get working.

Marking draft until I figure this out.

@toddbaert toddbaert marked this pull request as draft January 7, 2025 21:02
@toddbaert
Copy link
Member Author

Unfortunately, the nx-computed dependencies created by buildableProjectDepsInPackageJsonType no longer work (it was removed); this means we aren't properly computing deps at package time anymore. There's a new way to do this I need to get working.

Marking draft until I figure this out.

Looks like we can use @nx/dependency-checks for a comparable feature. I almost have it working.

Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
@toddbaert
Copy link
Member Author

toddbaert commented Jan 8, 2025

⚠️

There is one significant change in how this repo works: we no longer automatically compute the deps for all packages, BUT we instead throw a lint error if nx calculates that you have failed to include a dep in your package.json which you import in your code.

For example, flagd uses the lru-cache package. Because we import it in our ts files, if we DON'T include it in our package.json, we see this lint error (which causes the build to fail):

nx run providers-flagd:lint
      Linting "providers-flagd"...
      
      /home/todd/git/js-sdk-contrib/libs/providers/flagd/package.json
        9:3  error  The "providers-flagd" project uses the following packages, but they are missing from "peerDependencies":
          - lru-cache  @nx/dependency-checks
      
      ✖ 1 problem (1 error, 0 warnings)
        1 error and 0 warnings potentially fixable with the `--fix` option.

I think this is actually an improvement over the last behavior, since it will cause devs to think carefully about their deps.

⚠️

I have updated all the deps for all the packages appropriately according to this check. Please check the deps of your package.json.

Signed-off-by: Todd Baert <[email protected]>
},
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
},
{
"files": ["*.json"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new lint rule which ensures projects have all the dependencies they need.

@@ -1,7 +1,7 @@
import fs from 'fs';
import { FileFetch } from './file-fetch';
import { FlagdCore } from '@openfeature/flagd-core';
import { Logger } from '@openfeature/core';
import { Logger } from '@openfeature/server-sdk';
Copy link
Member Author

@toddbaert toddbaert Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid direct imports from core in server/web libs. It technically isn't a problem, but it adds a direct dep to core which is not needed.

@@ -1,4 +1,4 @@
import { EvaluationContext } from '@openfeature/server-sdk';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we we're importing from server in a web lib 😨

This was caught because the new lint tried to add the server-sdk to the deps.

@toddbaert toddbaert marked this pull request as ready for review January 8, 2025 20:52
@@ -1,17 +0,0 @@
services:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now use TestContainers to start/stop all containers during testing.

Copy link
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Nice update!

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.

8 participants