npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@iappx/vue-facing-di

v3.0.7

Published

Dependency injection for Vue class components — a tsyringe-powered wrapper around vue-facing-decorator.

Readme

Vue Facing DI

npm version license

A thin wrapper around vue-facing-decorator that brings dependency injection into Vue class components, powered by tsyringe.

Write your Vue components as classes exactly like you do with vue-facing-decorator, but declare constructor dependencies and let the tsyringe container resolve them for you.

How it works

vue-facing-decorator turns a decorated class into a Vue component by reading its properties, methods, computeds, watchers, props, etc. and assembling a Vue options object.

This library extends that pipeline: instead of instantiating the component class with new, it resolves the instance through the tsyringe container (container.resolve(cons)). Every class decorated with @Component is automatically registered as @injectable(), so its constructor dependencies are injected before the component's reactive data is derived from the instance.

The only thing you change in your components is the base class: use VueBase instead of the original Vue.

Installation

npm install @iappx/vue-facing-di tsyringe reflect-metadata

vue, tsyringe and reflect-metadata are peer requirements. tsyringe relies on decorator metadata, so make sure reflect-metadata is imported once at your application entry point:

import 'reflect-metadata'

TypeScript configuration

Decorator metadata must be enabled in your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Usage

Usage is identical to vue-facing-decorator, except the base class is VueBase instead of the original Vue.

Basic component

<template>
  <div>{{ greeting }}</div>
</template>

<script lang="ts">
import { Component, VueBase } from '@iappx/vue-facing-di'

@Component({})
export default class MyComponent extends VueBase {
  greeting = 'Hello world'
}
</script>

Injecting a dependency

Declare a service, register it in the container, and request it in the component constructor. Every constructor parameter must be annotated with tsyringe's @inject(...) decorator so the container knows what to resolve.

import { singleton } from 'tsyringe'

@singleton()
export class UserService {
  getName() {
    return 'Ada Lovelace'
  }
}
<template>
  <div>{{ userName }}</div>
</template>

<script lang="ts">
import { Component, VueBase } from '@iappx/vue-facing-di'
import { inject } from 'tsyringe'
import { UserService } from './UserService'

@Component({})
export default class UserCard extends VueBase {
  userName = ''

  constructor(@inject(UserService) private readonly userService: UserService) {
    super()
  }

  mounted() {
    this.userName = this.userService.getName()
  }
}
</script>

Note: always mark constructor parameters with @inject(Token). @Component applies tsyringe's @injectable(), so the class and all of its explicitly injected dependencies participate in the container's resolution graph. Import inject from tsyringe — it is distinct from the Inject decorator (Vue provide/inject) re-exported by this package.

API

The library re-exports the full decorator surface of vue-facing-decorator, so you can import everything from a single package:

import {
  Component,        // class decorator — builds the Vue component and registers it as injectable
  VueBase,          // base class to extend instead of `Vue`
  Setup, Ref, Watch, Prop, Provide, Inject, Emit, VModel, Model,
  Vanilla, Hook, BaseTypeIdentify, toNative,
} from '@iappx/vue-facing-di'

| Export | Description | | --- | --- | | Component | Class decorator that assembles the Vue component and marks the class @injectable(). | | VueBase | Base class that wires the component instance into the DI-aware build pipeline. Extend it instead of Vue. | | DiComponentBase | The underlying decorator factory behind Component (exported for advanced use). | | Re-exported decorators | Setup, Ref, Watch, Prop, Provide, Inject, Emit, VModel, Model, Vanilla, Hook, BaseTypeIdentify, toNative — behave exactly as in vue-facing-decorator. |

For the semantics of the individual decorators, refer to the vue-facing-decorator documentation.

Development

npm install       # install dependencies
npm run build     # compile TypeScript to ./lib
npm test          # run the Jest test suite

License

MIT