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

@koppajs/koppajs-vite-plugin

v1.0.4

Published

KoppaJS Vite Plugin - Seamless Integration for KoppaJS Framework with Vite

Downloads

67

Readme


What is this plugin?

@koppajs/koppajs-vite-plugin is the official build-time integration between Vite and KoppaJS Single File Components.

Its responsibility is deliberately narrow:

  • parse .kpa files
  • extract template, style, and script blocks
  • normalize and compile those blocks into deterministic ES modules
  • emit the contract consumed by @koppajs/koppajs-core

It is a transformation layer, not a runtime extension.


Features

  • native .kpa file support
  • TypeScript inside component scripts
  • SCSS and SASS compilation
  • explicit template, style, and script extraction
  • zero runtime behavior
  • fast HMR through Vite’s native mechanisms
  • ESM-first package output with CJS compatibility
  • minimal footprint and surface area

Installation

pnpm add @koppajs/koppajs-core
pnpm add -D @koppajs/koppajs-vite-plugin vite typescript
npm install @koppajs/koppajs-core
npm install -D @koppajs/koppajs-vite-plugin vite typescript

Add the plugin to vite.config.ts:

import { defineConfig } from 'vite'
import koppajsVitePlugin from '@koppajs/koppajs-vite-plugin'

export default defineConfig({
  plugins: [koppajsVitePlugin()],
})

No additional configuration is required for basic usage.

For most users, the fastest way to start from a working KoppaJS + Vite setup is still the official scaffolder:

pnpm create koppajs my-app

Requirements

For package consumers:

  • Vite ^7.0.0
  • TypeScript >=5.5 <6
  • @koppajs/koppajs-core in the consuming project

For local repository work:

  • Node.js >= 22
  • pnpm >= 10.24.0

Usage & Behavior

Once configured:

  • .kpa files are resolved by Vite like any other module
  • transformations occur during both development and production builds
  • Hot Module Replacement works through Vite’s normal module graph
  • output modules remain statically analyzable and deterministic

The plugin performs no runtime work and injects no global state. All behavior stays inside the build pipeline.


How it works

Each .kpa file is transformed into a plain JavaScript module.

This is a simplified view of the generated output:

export default {
  template: '<escaped-template>',
  style: '<compiled-css>',
  script: '(()=>{ /* controller */ })()',
}

Supported transformations include:

  • TypeScript to JavaScript
  • SCSS and SASS to CSS
  • composition-style controllers
  • legacy return {} controllers

The output format stays intentionally explicit so the KoppaJS core can remain small and predictable.


Debugging & Sourcemaps (Dynamic Code)

KoppaJS component scripts are executed dynamically at runtime by the core. Because of that, inline //# sourceMappingURL comments must not be embedded directly into executable script strings.

How sourcemaps are handled

  • sourceMappingURL and sourceURL comments are stripped during transformation
  • sourcemaps are preserved as structured data and exposed as scriptMap
  • the core runtime is responsible for reattaching sourcemaps when needed

If the runtime does not explicitly reattach sourcemaps, component scripts still execute correctly, but browser DevTools will not show the original source mapping.


Plugin -> Core Contract

This plugin emits ComponentSource objects with the following structure:

interface ComponentSource {
  contractVersion: number
  path: string
  template: string
  style: string
  script: string
  scriptMap: object | null
  deps: Record<string, () => Promise<unknown>>
  structAttr: string
}

Guarantees:

  • all string fields are JSON-serialized
  • emitted modules include contractVersion and normalized path metadata
  • TypeScript blocks are transpiled before emission
  • style blocks are compiled to plain CSS
  • templates include structural identity attributes for reconciliation

For deeper semantics, use the package docs:


Architecture & Governance

Project intent, contributor rules, release flow, and documentation contracts live in the local repo meta layer:

The file-shape contract for README.md, CHANGELOG.md, CODE_OF_CONDUCT.md, and CONTRIBUTING.md is defined in docs/specs/repository-documentation-contract.md.

Run the local document guard before committing:

pnpm run check:docs

Community & Contribution

Issues and pull requests are welcome:

https://github.com/koppajs/koppajs-vite-plugin/issues

Contributor workflow details live in CONTRIBUTING.md.

Community expectations live in CODE_OF_CONDUCT.md.


License

Apache License 2.0 — © 2026 KoppaJS, Bastian Bensch