unplugin-stencil

raw JSON →
0.4.1 verified Mon Apr 27 auth: no javascript

An unplugin wrapper around the Stencil compiler for use with Vite, Webpack, Rollup, esbuild, Nuxt, and other build tools. Version 0.4.1 is the current stable release. It provides a unified plugin interface across multiple bundlers, enabling Stencil component compilation in non-Stencil projects. Key differentiators: supports source maps (since 0.4.0), serializes builds to prevent stale output, and works with Astro, rspack, and Vue CLI. Peer dependencies include @stencil/core ^4.29.3 and various build tool versions. Release cadence is irregular; latest fixes address process.exit in writeBundle and Windows path support.

error Error: Cannot find module 'unplugin-stencil/vite'
cause Incorrect import path; subpath '/vite' missing.
fix
Ensure you have installed the package: npm install unplugin-stencil and use import stencil from 'unplugin-stencil/vite'.
error TypeError: stencil is not a function
cause Importing default export without calling it as a function.
fix
Use stencil({ options }) as a function call in your plugins array.
error Error: process.exit is not a function in writeBundle hook (v0.4.0)
cause Bug in version 0.4.0 where process.exit was called incorrectly.
fix
Upgrade to 0.4.1 which fixes this issue.
breaking In version 0.3.0, `ensureFreshBuild` was renamed to `getLatestBuild` and the build system switched to event-driven queue.
fix Update any custom build logic to use `getLatestBuild` and adjust for event-driven queue pattern.
deprecated Nuxt 2 support is deprecated and may be removed in future versions.
fix Migrate to Nuxt 3 if possible.
gotcha On Windows, path transformations may fail before version 0.3.4. Ensure you use >=0.3.4 for Windows support.
fix Upgrade to version 0.3.4 or later.
breaking In version 0.2.9, the ESM import issue with @stencil/core was fixed. Users on <0.2.9 may encounter ESM import errors.
fix Upgrade to 0.2.9 or later.
npm install unplugin-stencil
yarn add unplugin-stencil
pnpm add unplugin-stencil

Shows how to integrate unplugin-stencil with Vite using TypeScript. The plugin accepts Stencil compiler options as an argument.

// vite.config.ts
import { defineConfig } from 'vite';
import stencil from 'unplugin-stencil/vite';

export default defineConfig({
  plugins: [
    stencil({
      // Stencil compiler options (e.g., src: 'src/components', namespace: 'my-lib')
    }),
  ],
});