nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.5k stars 2.34k forks source link

Failed to run update-16-5-0 from @nx/storybook #18014

Closed simeon-raykov closed 1 year ago

simeon-raykov commented 1 year ago

Current Behavior

My team can't upgrade to v.16.5.0 because of storybook. It now requires us to have a local level tsconfig.json but we don't think we need that because it will only inherit from the base config and it will add additional complexity. This is a demo of our project structure:

├── .storybook/ │ ├── main.ts │ ├── manager.ts │ ├── preview-head.html │ ├── test-runner.ts │ ├── tsconfig.json ├── apps/ │ ├── demo/ │ │ ├── host/ | │ │ ├── components/ | │ │ ├───.stories.tsx │ │ ├── remote/ | │ │ ├── components/ | │ │ ├───.stories.tsx │ │ ├── storybook/ | │ │ ├── .storybook/ | │ │ ├─── main.ts | │ │ ├─── manager.ts | │ │ ├─── preview.ts | │ │ ├─── test-runner.ts | │ │ ├─── project.json ├── libs/ │ ├── demo/ │ │ ├── ui/ | │ │ ├── src/ | │ │ ├───*.stories.tsx

We have made all of the configurations needed in our root level .storybook and only inherit them in our demo scoped storybook app. Our demo scoped storybook main.ts file only imports the stories like this:

 stories: [
    `${workspacePath}/libs/demo/ui/src/**/*.mdx`,
    `${workspacePath}/libs/demo/ui/src/**/*.stories.@(js|jsx|ts|tsx)`,
    `${workspacePath}/apps/demo/app/**/*.stories.@(js|jsx|ts|tsx)`
  ]

Expected Behavior

Migration should run successfully without the need of additional tsconfig.json

Nx Report

Node   : 19.7.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx                 : 16.4.1
   @nx/js             : 16.4.1
   @nx/jest           : 16.4.1
   @nx/linter         : 16.4.1
   @nx/workspace      : 16.4.1
   @nx/cypress        : 16.4.1
   @nx/devkit         : 16.4.1
   @nx/eslint-plugin  : 16.4.1
   @nx/next           : 16.4.1
   @nx/react          : 16.4.1
   @nx/storybook      : 16.4.1
   @nrwl/tao          : 16.4.1
   @nx/vite           : 16.4.1
   @nx/web            : 16.4.1
   @nx/webpack        : 16.4.1
   nx-cloud           : 16.0.5
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @jscutlery/semver : 3.0.0

Failure Logs

>  NX   Failed to run update-16-5-0 from @nx/storybook. This workspace is NOT up to date!

 >  NX   Cannot find apps/demo/storybook/.storybook/tsconfig.json

   Pass --verbose to see the stacktrace.

error Command failed with exit code 1.

Operating System

LouisLecouturier commented 1 year ago

Hey Simeon ! I think I had the same issue (see #17966) I think they are working on it

mandarini commented 1 year ago

Hi there @simeon-raykov ! Thanks for filing an issue! It would be super useful if you could provide a small reproduction repository of the issue you are experiencing, and how this is causing you trouble in this case! If you don't want the project-level tsconfig you may remove it, but please let me know how this is blocking you!

simeon-raykov commented 1 year ago

@mandarini It is blocking me because there is now a test that searches for tsconfig.json when running the command "yarn nx migrate --run-migrations"

Lp-Francois commented 1 year ago

Hey!

I still get a similar error on linting with the latest 16.6.0-beta.1 🤔

On linting with @nx/linter:eslint I get the following errors:

...
/Users/francois/Projects/org/repo/libs/widgets/my-widget/v2/tailwind.config.js
  0:0  error  Parsing error: Cannot read file '/users/francois/projects/org/repo/libs/widgets/my-widget/v2/.storybook/tsconfig.json'
✖ 67 problems (67 errors, 0 warnings)

Seems to happen for all projects using storybook, there is no tsconfig.json in the .storybook folder. Only at a project level.

Currently migrating from 15.6.3

Note: creating an empty tsconfig.json file in the .storybook folders seem to stop the lint error

mandarini commented 1 year ago

@Lp-Francois I adjusted our migrator to change that as well. Can I see your eslintrc file please? Does it contain the path to that file?

Lp-Francois commented 1 year ago

Hey @mandarini ,

The .eslintrc.json in one of the project failing looks like this:

{
  "extends": ["plugin:@nx/react", "../../../../.eslintrc.js"],
  "ignorePatterns": ["!**/*"],
  "overrides": [
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "parserOptions": {
        "project": [
          "libs/widgets/my-widget/v2/tsconfig.*?.json",
          "libs/widgets/my-widget/v2/.storybook/tsconfig.json"
        ]
      },
      "rules": {}
    },
    {
      "files": ["*.ts", "*.tsx"],
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "rules": {}
    }
  ]
}

So yes it contains the path to .storybook/tsconfig.json. Should I remove it manually?

I have a tsconfig.storybook.json in the same folder, and no tsconfig.json in .storybook

Note: deleting the line "libs/[...any project path...]/.storybook/tsconfig.json" in all storybook projects seems to pass the linting 👌 I guess the migrator should delete the line if present?

mandarini commented 1 year ago

Yes, that's what I added in the migrator! :)

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.