Skip to main content
Version: 7.x

Using bundlers

InversifyJS can be used with any bundler that supports transpiling TypeScript legacy decorators and emitting TypeScript class metadata.

If your bundler does not transpile TypeScript legacy decorators, you won't be able to use InversifyJS without a plugin that does it.

If your bundler does not emit TypeScript class metadata, InversifyJS won't be able to provide the following features:

  • Autobinding.
  • Class constructor parameters or properties without the need to include an @inject decorator.

esbuild

esbuild does not support transpiling TypeScript legacy decorators as explained in this issue.

Rollup

You can use the @rollup/plugin-typescript plugin to successfully transpile TypeScript code with legacy decorators.

Vite

Vite uses esbuild under the hood, so it also does not support transpiling TypeScript legacy decorators. However, you can use the unplugin-swc plugin to transpile TypeScript legacy decorators.

vite.config.ts
import swc from "unplugin-swc";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [
// Vite plugin
swc.vite(),
],
});

Refer to this issue for more information.

Webpack

You can use the ts-loader plugin to successfully transpile TypeScript code with legacy decorators.