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

@shadow-js/vite

v0.3.0

Published

Vite plugin for ShadowJS (JSX + transforms via SWC)

Readme

ShadowJS Vite Plugin

npm version TypeScript License: MIT

Vite plugin for ShadowJS that provides seamless development experience with hot reload, JSX compilation, and optimized build process.

✨ Features

  • ⚡ Hot Module Replacement: Instant updates during development
  • 🎯 JSX Compilation: Automatic ShadowJS JSX transformations
  • 🔧 Zero Configuration: Works out of the box with sensible defaults
  • 🎨 TypeScript Support: Full TypeScript and TSX compilation
  • 📦 Optimized Builds: Production-ready bundle optimization
  • 🔍 Source Maps: Accurate debugging with source map support
  • 🎭 Development Server: Fast development server with HMR
  • 📱 Modern Standards: ES2022+ with modern browser support

📦 Installation

npm install @shadow-js/vite

Install together with ShadowJS:

npm install @shadow-js/core @shadow-js/vite

🚀 Quick Start

Basic Setup

vite.config.ts

import { defineConfig } from "vite";
import shadow from "@shadow-js/vite";

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

src/App.tsx

import { useStore, Show } from "@shadow-js/core";

function App() {
  const [count, setCount] = useStore(0);

  return (
    <div>
      <h1>ShadowJS Counter</h1>
      <button onClick={() => setCount((c) => c + 1)}>Count: {count()}</button>
      <Show when={count() > 5}>
        <p>🎉 You reached {count()}!</p>
      </Show>
    </div>
  );
}

export default App;

src/main.ts

import { render } from "@shadow-js/core";
import App from "./App";

render(App, document.getElementById("app")!);

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ShadowJS App</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>

Development Commands

# Start development server
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

🎯 How It Works

The plugin integrates ShadowJS with Vite's build pipeline:

1. Development Mode

  • Hot Module Replacement: Instant updates without page refresh
  • Source Maps: Accurate debugging information
  • Error Overlay: Clear error messages in browser

2. Build Process

  • JSX Compilation: Transforms TSX/JSX using ShadowJS compiler
  • TypeScript Compilation: Converts TypeScript to JavaScript
  • JSX Runtime Injection: Automatically imports ShadowJS runtime
  • Code Splitting: Optimizes bundle size with code splitting
  • Minification: Production-ready code minification

3. Plugin Architecture

Source Code (.tsx)
    ↓
ShadowJS Compiler (JSX → Reactive)
    ↓
SWC (TypeScript → JavaScript)
    ↓
Vite (Bundling & Optimization)
    ↓
Output Bundle

🔧 Configuration

Basic Configuration

// vite.config.ts
import { defineConfig } from "vite";
import shadow from "@shadow-js/vite";

export default defineConfig({
  plugins: [shadow()],
  // Your other Vite configuration
});

Advanced Configuration

// vite.config.ts
import { defineConfig } from "vite";
import shadow from "@shadow-js/vite";

export default defineConfig({
  plugins: [
    shadow({
      // Plugin-specific options (future)
    }),
  ],

  // Vite configuration
  server: {
    port: 3000,
    open: true,
  },

  build: {
    target: "es2022",
    minify: "esbuild",
  },

  // TypeScript configuration
  esbuild: {
    // Vite handles TypeScript compilation
  },
});

With Other Vite Plugins

The ShadowJS plugin works well with other Vite plugins:

import { defineConfig } from "vite";
import shadow from "@shadow-js/vite";
import { viteStaticCopy } from "vite-plugin-static-copy";

export default defineConfig({
  plugins: [
    shadow(),
    viteStaticCopy({
      targets: [
        {
          src: "static/*",
          dest: "assets",
        },
      ],
    }),
  ],
});

🏗️ Plugin Architecture

Core Components

| Component | Description | | ---------------------- | --------------------------------------------- | | JSX Transform | Converts ShadowJS JSX to reactive expressions | | TypeScript Support | Handles TypeScript compilation via SWC | | HMR Integration | Manages hot module replacement | | Source Maps | Generates source maps for debugging | | Error Handling | Provides clear error messages |

Transformation Pipeline

  1. File Detection: Identifies .tsx and .jsx files
  2. ShadowJS Compilation: Applies JSX transformations
  3. SWC Processing: Handles TypeScript/JSX to JavaScript conversion
  4. Runtime Injection: Adds necessary ShadowJS imports
  5. Source Map Generation: Creates debugging source maps

Development Features

  • Fast Refresh: Instant updates during development
  • Error Boundaries: Development-friendly error handling
  • Console Integration: Clear logging and debugging messages
  • Type Checking: Real-time TypeScript error reporting

🎨 Development Experience

Hot Module Replacement

The plugin provides seamless HMR for ShadowJS components:

// This component will hot-reload automatically
function Counter() {
  const [count, setCount] = useStore(0);

  return <button onClick={() => setCount((c) => c + 1)}>{count()}</button>;
}

TypeScript Integration

Full TypeScript support with IntelliSense:

// TypeScript types work perfectly
function UserComponent({ user }: { user: User }) {
  const [isEditing, setIsEditing] = useStore(false);

  return (
    <div>
      <h2>{user().name}</h2>
      <button onClick={() => setIsEditing((v) => !v)}>
        {isEditing() ? "Cancel" : "Edit"}
      </button>
    </div>
  );
}

🤝 Contributing

We welcome any contributions! See the Contributing Guide for details.

Areas for contribution:

  • Performance optimizations
  • New plugin features
  • Better error messages
  • Enhanced TypeScript support
  • Additional build optimizations

📄 License

MIT License - see LICENSE for details.

📞 Support


Built by Jehaad AL-Johani for the ShadowJS ecosystem.