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

vite-tsconfig-paths compatibility #222

Closed
Mushus opened this issue Sep 22, 2024 · 1 comment · Fixed by #231
Closed

vite-tsconfig-paths compatibility #222

Mushus opened this issue Sep 22, 2024 · 1 comment · Fixed by #231
Labels
bug Something isn't working

Comments

@Mushus
Copy link

Mushus commented Sep 22, 2024

What version of HonoX are you using?

0.1.23

What steps can reproduce the bug?

When an island component is called from a component imported via an alias defined by vite-tsconfig-paths, the child elements of the HasIslands component never render.

  1. Create an x-basic project:
    npm create hono@latest
  2. Install vite-tsconfig-paths:
    npm i -D vite-tsconfig-paths
  3. Define compilerOptions.paths in tsconfig.json:
    {
      "compilerOptions": {
      ︙
    +  "baseUrl": ".",
    +  "paths": {
    +    "@/*": ["app/*"]
    +  }
      }
      ︙
    }
  4. Add vite-tsconfig-paths plugin to vite.config.ts:
    +import tsconfigPaths from "vite-tsconfig-paths";
    
    export default defineConfig({
      plugins: [
        ︙
    +    tsconfigPaths()
      ],
    });
  5. Create a component app/SomeComponent.tsx :
    import Counter from "./islands/counter";
    export default function SomeComponent() {
      return <Counter />;
    }
  6. Update app/index.tsx to render SomeComponent:
    -import Counter from "../islands/counter";
    +import SomeComponent from "@/SomeComponent";
    ︙
    export default createRoute((c) => {
      ︙
      return c.render(
        ︙
    -      <Counter />
    +      <SomeComponent />
        ︙
      );
    });
  7. (Optional) If we want to check in the dev build, we add the HasIslands component in app/routes/_renderer.tsx:
    ︙
    export default jsxRenderer(({ children, title }) => {
      return (
        ︙
    -        <Script src="/app/client.ts" async />
    +        <HasIslands>
    +          <Script src="/app/client.ts" async />
    +        </HasIslands>
        ︙
      );
    });

What is the expected behavior?

When an island component is used, the child elements of the HasIslands component are rendered.

What do you see instead?

It can be avoided by defining resolve.alias in the vite.config.ts file instead.

Additional information

This means that the honox/server Script component, as well as this issue, will not work properly with the island component in production builds.

@Mushus Mushus added the bug Something isn't working label Sep 22, 2024
@yusukebe
Copy link
Member

yusukebe commented Oct 5, 2024

Hi @Mushus

Thank you for the issue. I've fixed and released the new version v0.1.26. Try it.

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

Successfully merging a pull request may close this issue.

2 participants