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

Unable to resolve @theme in swizzled component file #816

Closed
Pratosh22 opened this issue May 3, 2024 · 5 comments
Closed

Unable to resolve @theme in swizzled component file #816

Pratosh22 opened this issue May 3, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Pratosh22
Copy link

Describe the bug

Swizzled components in typescript cannot resolve "theme" components

Expected behavior

Swizzled components should be able to resolve "theme" components

Steps to reproduce

1.Install docusaurus-openapi-plugin and theme version "3.0.0-beta.8"
2.Run yarn swizzle
3.Go to any file which imports file from "theme", it will be not be able to resolve

Screenshots

Screenshot 2024-05-03 at 2 41 07 PM

Your Environment

  • Version used: 3.0.0-beta.8
  • Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): Nodejs v18
  • Operating System and version (desktop or mobile): MacOS
@Pratosh22 Pratosh22 added the bug Something isn't working label May 3, 2024
@alienzhangyw
Copy link

Just add paths in your tsconfig.json

{
  // This file is not used in compilation. It is here just for a nice editor experience.
  "extends": "@docusaurus/tsconfig",
  "compilerOptions": {
    "baseUrl": ".",
    "lib": [
      "ES2021",
    ],
    "jsx": "react",
    "paths": {
      "@theme/*": [
        "src/theme/*"
      ],
    }
  }
}

@Pratosh22
Copy link
Author

This worked, but when i swizzle any component from APIExplorer it breaks the document and throws an error ,
Screenshot 2024-05-06 at 12 45 01 PM
It was mentioned in #633 as well.

@alienzhangyw
Copy link

This worked, but when i swizzle any component from APIExplorer it breaks the document and throws an error , Screenshot 2024-05-06 at 12 45 01 PM It was mentioned in #633 as well.

I swizzled the ApiExplorer root directory and ApiItem directory, didn't see this error.

image

If you are using yarn pnp as package manager, try to switch to nodeLinker: node-modules.

@Pratosh22
Copy link
Author

Just tried the above, The error does not occur when i swizzle ApiExplorer and ApiItem Directory but it comes when i swizzle few files from ApiExplorer and do not swizzle the rest of files. Is this the expected behaviour or am i missing something?
Screenshot 2024-05-06 at 4 03 39 PM
The below are the files i swizzled
Screenshot 2024-05-06 at 4 04 18 PM

@alienzhangyw
Copy link

alienzhangyw commented May 7, 2024

Just tried the above, The error does not occur when i swizzle ApiExplorer and ApiItem Directory but it comes when i swizzle few files from ApiExplorer and do not swizzle the rest of files. Is this the expected behaviour or am i missing something? Screenshot 2024-05-06 at 4 03 39 PM The below are the files i swizzled Screenshot 2024-05-06 at 4 04 18 PM

Yes, you need many other files because ParamFormItems uses a FormItem component, and a react-hook-form context provided in Response component. Basicly you need to swizzle all related files to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants