# unplugin-print-type

> Register global imports on demand for Vite and Webpack

Latest version **0.1.2** (published 2023-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install unplugin-print-type
pnpm add unplugin-print-type
yarn add unplugin-print-type
bun add unplugin-print-type
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-10-17 |
| First published | 2022-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 403.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | m0ksem |
| Keywords | unplugin, vite, webpack, rollup, transform |

## Links

- npm: https://www.npmjs.com/package/unplugin-print-type
- Repository: https://github.com/m0ksem/unplugin-print-type
- Homepage: https://github.com/m0ksem/unplugin-print-type#readme
- Issues: https://github.com/m0ksem/unplugin-print-type/issues
- npm.io page: https://npm.io/package/unplugin-print-type

## Dependencies (2)

- [ts-morph](https://npm.io/package/ts-morph.md) ^15.1.0
- [unplugin](https://npm.io/package/unplugin.md) ^1.4.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2023-10-17
- 0.1.1 — 2023-10-16
- 0.1.0 — 2023-10-15
- 0.0.3 — 2022-09-25
- 0.0.2 — 2022-09-13

## README

# unplugin-print-type

Experimental TS type printer. 

Print TS type deeply handle all subtypes. Useful if you want to document types.

## Features
- Render type during build (Zero runtime-code)
- Render type aliases and interfaces to string
- Resolve imported types

## Usage

```ts
import type { UserRole } from './user'

interface User {
  name: string
  role: UserRole
}

console.log(`User type: ${PrintType<User>()}`)
```

Output
```plain
User type: {
  name: string
  role: 'admin' | 'user'
}
```

## Install

```bash
npm i unplugin-print-type
```

<details>
<summary>Vite</summary><br>

```ts
// vite.config.ts
import Untype from 'unplugin-print-type/vite'

export default defineConfig({
  plugins: [
    Untype({ /* options */ }),
  ],
})
```

Example: [`playground/`](./playground/)

<br></details>

<details>
<summary>Webpack</summary><br>

```ts
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-print-type/webpack')({ /* options */ })
  ]
}
```

<br></details>

<details>
<summary>Nuxt</summary><br>

```ts
// nuxt.config.js
export default {
  buildModules: [
    ['unplugin-print-type/nuxt', { /* options */ }],
  ],
}
```

> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)

<br></details>

<details>
<summary>Vue CLI</summary><br>

```ts
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-print-type/webpack')({ /* options */ }),
    ],
  },
}
```

<br></details>

---
_Source: https://npm.io/package/unplugin-print-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
