@ryoppippi/unplugin-typia v2.6.5
unplugin-typia
unplugin for Typia
Why
Typia is fantastic, but it is hard to setup, even for frontend development.
If you use some bundlers for frontend like Vite, it is even harder to setup.
This unplugin aims to make it easier to use Typia in your projects.
Install
First, install unplugin-typia:
# npm
npm install -D @ryoppippi/unplugin-typiaThen, install typia:
# install typia! (nypm detects your PM ✨)
npx nypm add typia
# setup typia!
npx typia setup
# pnpm dlx typia setup
# yarn dlx typia setup
# after installing typia, run prepare script
npm run prepareMore details about setting up Typia can be found in the Typia Docs.
Then, add the unplugin to your favorite bundler:
// vite.config.ts
import UnpluginTypia from '@ryoppippi/unplugin-typia/vite';
export default defineConfig({
	plugins: [
		UnpluginTypia({ tsconfig: './tsconfig.app.json' /* options */ }), // should be placed before other plugins like `react`, `svetle`, etc.
	],
});When using typia with types imported from non-relative paths like tsconfig
compilerOptions.pathsor relative to tsconfigcompilerOptions.baseUrl, they must be defined in vite.config.ts under resolve.alias in order to be resolved, according to vite's resolution mechanism.
Examples:
// esbuild.config.js
import UnpluginTypia from '@ryoppippi/unplugin-typia/esbuild';
export default {
	plugins: [
		UnpluginTypia({ /* options */ }),
	],
};Examples:
// next.config.mjs
import unTypiaNext from 'unplugin-typia/next';
/** @type {import('next').NextConfig} */
const nextConfig = { /* your next.js config */};
/** @type {import("unplugin-typia").Options} */
const unpluginTypiaOptions = { /* your unplugin-typia options */ };
export default unTypiaNext(nextConfig, unpluginTypiaOptions);
// you can omit the unplugin-typia options when you don't need to customize it
// export default unTypiaNext(nextConfig);Examples:
Example 1: Using for building script
// build.ts
import UnpluginTypia from '@ryoppippi/unplugin-typia/bun';
await Bun.build({
	entrypoints: ['./index.ts'],
	outdir: './out',
	plugins: [
		UnpluginTypia({ /* your options */})
	]
});For building the script:
bun run ./build.ts
node ./out/index.jsCheck the Plugins – Bundler | Bun Docs for more details.
Example 2: Using for running script
// preload.ts
import { plugin } from 'bun';
import UnpluginTypia from '@ryoppippi/unplugin-typia/bun';
plugin(UnpluginTypia({ /* your options */}));# bun.toml
preload = "preload.ts"
[test]
preload = "preload.ts"For running the script:
bun run ./index.tsCheck the Plugins – Runtime | Bun Docs for more details.
// rollup.config.js
import UnpluginTypia from '@ryoppippi/unplugin-typia/rollup';
export default {
	plugins: [
		UnpluginTypia({ /* options */ }),
	],
};Examples:
// webpack.config.js
const { default: UnpluginTypia } = require('@ryoppippi/unplugin-typia/webpack');
module.exports = {
	plugins: [
		UnpluginTypia({ /* options */ }),
	],
};You can find examples in the examples/.
Supported File Extensions
- .ts
- .tsx
- .mts
- .mtsx
- .svelte(only script tag with- lang="ts")
Development
This repository is a monorepo managed by Bun.
bun i --frozen-lockfileAcknowledgements
This project started as an unofficial integration of Typia for bundlers. Now, this plugin is one of the official integrations of Typia and is sponsored by @samchon (the creator of Typia).
LICENSE
10 months ago
10 months ago
11 months ago
10 months ago
6 months ago
6 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
5 months ago
6 months ago
7 months ago
8 months ago
8 months ago
5 months ago
5 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago