Skip to content

API for Typia to communicate dependencies with dev-mode plugins #1722

@kahoot-karl

Description

@kahoot-karl

Hello!

The official vite plugin, unplugin-typia, is not properly handling HMR. Pure type-imports are stripped by esbuild (or oxc, depending on which version of vite you use), this means that the dependency graph is not built properly for this sample code:

import typia from 'typia';
import { MyType } from './types'; // Will be removed when building the dependency graph

export const validator = typia.createIs<MyType>();

Because import { MyType } from './types'; gets removed, updates to the file will not be in sync with the validator. It seems like hacks like importsNotUsedAsValues in the tsconfig might improve this, but comes with other downsides. I was trying to fork the plugin to fix this, but building this dependency-graph within vite plugin api is proving to be quite difficult.

I was thinking if it would be possible to recursively lookup all the dependencies on the Typescript level, so that Typia could provide this to the plugin which would then know which imports to add explicitly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions