@gjsify/esbuild-plugin-deepkit
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

@gjsify/esbuild-plugin-deepkit

A esbuild plugin for the the compiler/transformer of @deepkit/type.

Example

src/index.ts:

import { deserialize } from '@deepkit/type';

interface Config {
    color: string;
}

interface User {
    id: number;
    createdAt: Date;
    firstName?: string;
    lastName?: string;
    config: Config;
    username: string;
}

//deserialize JSON object to real instances
const user = deserialize<User>({
    id: 0,
    username: 'peter',
    createdAt: '2021-06-26T12:34:41.061Z',
    config: {color: '#221122'},
});


console.log(user.createdAt instanceof Date); // true

esbuild.mjs:

import { build } from 'esbuild';
import { deepkitPlugin } from '@gjsify/esbuild-plugin-deepkit';

build({
    entryPoints: ['src/index.ts'],
    bundle: true,
    minify: true,
    outfile: 'dist/index.js',
    format: 'esm',
    platform: "node",
    external: ['@deepkit/type'],
    plugins: [deepkitPlugin()],
});

Start:

node dist/index.js
-> true

/@gjsify/esbuild-plugin-deepkit/

    Package Sidebar

    Install

    npm i @gjsify/esbuild-plugin-deepkit

    Weekly Downloads

    9

    Version

    0.0.4

    License

    none

    Unpacked Size

    9.67 kB

    Total Files

    10

    Last publish

    Collaborators

    • ewlsh
    • schanz
    • jumplink