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

References in Nuxt setup #117

Merged
merged 15 commits into from
Nov 11, 2024
Merged

References in Nuxt setup #117

merged 15 commits into from
Nov 11, 2024

Conversation

daniilsapa
Copy link
Collaborator

Resolves #94

@illright
The cause of the issue was not exactly in the Nuxt setup. The problem was that compilerOption.paths specified in config extensions ("extends": "./.nuxt/tsconfig.json") were not resolved and thus path aliases like @/, ~/ didn't work.

So such paths from extensions were applied to the FSD root.

 {
     "~": [
        ".."
      ],
      "~/*": [
        "../*"
      ],
      "@": [
        ".."
      ],
      "@/*": [
        "../*"
      ],
}

I made changes to transform such paths from ../* to /* and then apply them to the root.

Nuxt setup extends a default config from the .nuxt folder it helped us to uncover this issue.

Sorry for the delay!

Copy link
Member

@illright illright left a comment

Choose a reason for hiding this comment

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

Could you also resolve the conflicts? Recently there's been a change to that file which did a similar thing, I wonder if your changes overlap with it or not

@daniilsapa
Copy link
Collaborator Author

Got it, yes, let me resolve the conflicts first. Then I'll fix the function and also now I see some other flaws of my solution

@daniilsapa
Copy link
Collaborator Author

daniilsapa commented Nov 11, 2024

@illright

I fixed the first issue that we discussed in the morning by always transforming compilerOptions.paths to absolute, so now we don't have to worry about losing context when running Steiger from a folder other than the one where the original tsconfig is placed.

Regarding the 2nd problem

https://stackblitz.com/edit/nuxt-starter-ap1c4y?file=README.md

How to reproduce

When /src/features/session/logout/index has .js extension. It reports this diagnostic, from which we can see that the file is noticed by the tool.
Screenshot 2024-11-11 at 18 29 00

When /src/features/session/logout/index has .vue extension. It reports the following diagnostic, from which we can see that the tool does not see that the file is imported in other files.
Screenshot 2024-11-11 at 18 29 44

Don't forget to wrap/unwrap the code inside /src/features/session/logout/index with <script></script> when changing extensions

You can temporarily change fileExists, directoryExists parameters from these:

Screenshot 2024-11-11 at 18 38 27 to these Screenshot 2024-11-11 at 18 37 45 (I made that change locally for insignificant-slice)

Then you'll be able to see how it goes through different possible options (like .../logout.ts, .../logout.js, .../logout/index.ts, .../logout/index.js, etc) and then fails when runs out of further options

@daniilsapa
Copy link
Collaborator Author

resolveDependency from .../steiger-plugin-fsd/src/_lib/resolve-dependency.ts uses resolveImport from @feature-sliced/filesystem. It looks like we need to add some wrapper in resolveImport to add .vue extension case. Also, maybe we need to create space to gracefully add more custom extensions, but I'm not sure it's inside the score of the task, we can create a quick fix and an issue to design and implement a module responsible for custom extensions

illright
illright previously approved these changes Nov 11, 2024
@illright illright merged commit b0dc51b into master Nov 11, 2024
7 checks passed
@illright illright deleted the feature/references-in-nuxt-setup branch November 11, 2024 20:21
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.

References to features aren't detected in a Nuxt setup
2 participants