Socket
Book a DemoInstallSign in
Socket

esbuild-plugin-decorator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-decorator

ESBuild plugin for decorator compilation.

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
953
-13.83%
Maintainers
1
Weekly downloads
 
Created
Source

esbuild-plugin-decorator

ESBuild plugin to handle TypeScript decorators compilation.

  • Support compilation by typescript / @swc/core.
  • Support typescript/swc config file load.
  • (WIP)Integration with Nx.

Usage

# install peer dependencies
# install @swc/core if you want to use swc as compiler
npm i esbuild typescript @swc/core -D
npm i esbuild-plugin-decorator -D
pnpm i esbuild-plugin-decorator -D
yarn add esbuild-plugin-decorator -D
import { build } from 'esbuild';
import { esbuildPluginDecorator } from 'esbuild-plugin-decorator';

(async () => {
  const res1 = await build({
    entryPoints: ['./demo.ts'],
    bundle: true,
    outfile: './dist/main.js',
    plugins: [
      esbuildPluginDecorator({
        tsconfigPath: 'apps/nest-app/tsconfig.app.json',
      }),
    ],
  });
})();

Configuration

export interface ESBuildPluginDecoratorOptions {
  // tsconfig path (tsconfig.json)
  // required even you're using swc as compiler
  // if not specified, will search tsconfig.json(relative to cwd option) by default
  tsconfigPath?: string;
  // swc config path (.swcrc)
  swcrcPath?: string;

  // force specified compiler for all code compilation
  // (even no decorators are found)
  // if set to false, plugin will be skipped when no decorators are found
  force?: boolean;

  // default: process.cwd()
  cwd?: string;

  // use typescript or @swc/core for decorator compilation
  // default: tsc
  compiler?: 'tsc' | 'swc';

  // when innx project, will search tsconfig.base.json
  // when tsconfigPath is not speficied
  // there will be more customization for nx-workspace in the future
  // default: false
  isNxProject?: boolean;

  // extra compile options
  // will override config from config file
  tscCompilerOptions?: TSCCompileOptions;
  swcCompilerOptions?: SWCCompileOptions;

  // verbose logging
  // log info about plugin skipped / decorators not found / current configuration
  // default: false
  verbose?: boolean;
}

Keywords

esbuild

FAQs

Package last updated on 27 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts