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

fileMap is missing files after upgrade from v19.4.4 to v19.5.0 #28000

Open
1 of 4 tasks
cainlevy opened this issue Sep 19, 2024 · 3 comments
Open
1 of 4 tasks

fileMap is missing files after upgrade from v19.4.4 to v19.5.0 #28000

cainlevy opened this issue Sep 19, 2024 · 3 comments
Assignees
Labels
scope: linter Issues related to Eslint support in Nx type: bug

Comments

@cainlevy
Copy link

cainlevy commented Sep 19, 2024

Current Behavior

After upgrading to v19.7.4 v19.5.0, the @nx/dependency-checks rule believes that some of my packages have obsolete dependencies, while in fact the dependencies are referenced by existing code and are properly included with v18.3.1 v19.4.4.

So far, the problem appears to be that the files importing the dependencies are no longer included in the file-map.json and thus are not parsed for dependencies. The pattern I am observing is that file-map.json does not include the contents of src/lib for any of my packages, and this will miss any dependencies referenced by those files.

NX v19 v19.5.0 shows the following in fileMap.projectFileMap.validators:

        {
          "file": "packages/validators/src/index.ts",
          "hash": "3051616070451820306"
        },

NX v18 v19.4.4 includes more:

        {
          "file": "packages/validators/src/index.ts",
          "hash": "3051616070451820306"
        },
        {
          "file": "packages/validators/src/lib/validators.spec.ts",
          "hash": "11102733480037190733"
        },
        {
          "file": "packages/validators/src/lib/validators.ts",
          "hash": "1428833592629210108",
          "deps": [
            "npm:date-fns"
          ]
        },

Expected Behavior

I expect the project-graph.json will reference all files in my packages and be aware of all dependencies used by those projects.

GitHub Repo

No response

Steps to Reproduce

  1. Install NX v19.5.0
  2. Create a TypeScript test package with packages/test/src/lib/file.ts
  3. Add a dependency to packages/test/package.json and import it from file.ts
  4. Run @nx/dependency-checks lint
  5. Observe that it believes the dependency to be obsolete
  6. Observe that packages/test/src/lib/file.ts is missing from .nx/workspace-data/project-graph.json and from .nx/workspace-data/file-map.json

Nx Report

Node           : 20.11.1
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.2.4

nx                 : 19.7.4
@nx/js             : 19.7.4
@nx/jest           : 19.7.4
@nx/linter         : 19.7.4
@nx/eslint         : 19.7.4
@nx/workspace      : 19.7.4
@nx/cypress        : 19.7.4
@nx/devkit         : 19.7.4
@nx/esbuild        : 19.7.4
@nx/eslint-plugin  : 19.7.4
@nx/node           : 19.7.4
@nx/react          : 19.7.4
@nx/rollup         : 19.7.4
@nx/storybook      : 19.7.4
@nrwl/tao          : 19.7.4
@nx/vite           : 19.7.4
@nx/web            : 19.7.4
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/rollup/plugin

Failure Logs

5:5  error  The "date-fns" package is not used by "validators" project  @nx/dependency-checks

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@cainlevy
Copy link
Author

I bisected the problem by stepping through versions with the following commands:

npx nx migrate $version
npm i
rm -r .nx
npx nx reset
npx nx run validators:lint

The problem begins with 19.5.0. It does not exist with 19.4.4.

@cainlevy
Copy link
Author

cainlevy commented Sep 19, 2024

Now I am getting the issue with a clean upgrade to 19.4.4 and even 19.0.8.

I can't figure out why this appears non-deterministic.

@cainlevy
Copy link
Author

My last comment was caused by confusion from a separate issue: #26675

When I control for this second bug, I once again see the fileMap problem appear with v19.5.0.

@cainlevy cainlevy changed the title fileMap is missing files after upgrade from v18.3.1 to v19.7.4 fileMap is missing files after upgrade from v19.4.4 to v19.5.0 Sep 20, 2024
@jaysoo jaysoo added the scope: linter Issues related to Eslint support in Nx label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants