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 tsconfig resolution in Nextjs projects #22160

Merged

Conversation

valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Apr 19, 2023

Closes N/A

What I did

I have fixed the way how we try to resolve the app's tsconfig.json. In monorepositories very likely each app/lib has its own tsconfig file, which extends the base root config. In this case, we DON'T want to load the root tsconfig file, but the app/lib config file instead. The resolution algorithm now searches for the following paths in the mentioned order:

  • <cwd>/<project>/.storybook/tsconfig.json
  • <cwd>/<project>/tsconfig.json
  • <cwd>/tsconfig.json

How to test

  1. Checkout https://github.com/mandarini/nx-next-storybook-paths
  2. Copy/Paste @storybook/nextjs dist folder into project.
  3. npx nx build-storybook next-app shouldn't fail

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@mandarini
Copy link
Contributor

Works as expected now!!! THANK YOU SO MUCH!!!!!

Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

LGTM!

@valentinpalkovic valentinpalkovic merged commit ac64c1d into next Apr 19, 2023
@valentinpalkovic valentinpalkovic deleted the valentin/fix-tsconfig-resolution-in-nextjs-projects branch April 19, 2023 11:51
@shilman
Copy link
Member

shilman commented Apr 24, 2023

@valentinpalkovic @yannbf do you want this to be patched back to 7.0.x? If so, please label with patch

@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Apr 24, 2023
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label May 3, 2023
shilman pushed a commit that referenced this pull request May 3, 2023
…lution-in-nextjs-projects

Fix tsconfig resolution in Nextjs projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug nextjs patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants