Registry / devops / rollup-plugin-drupal-sdc-generator

rollup-plugin-drupal-sdc-generator

JSON →
library1.1.11jsnpmunverified

A Rollup plugin that generates Single Directory Components (SDCs) for embedding JavaScript applications into Drupal modules or themes. Current stable version is 1.1.11, released with moderate maintenance cadence. It automates creation of .component.yml, .twig, and other SDC files from templates, replacing placeholders like [name] with component names. Supports both string and object configuration for template directories. Designed specifically for Drupal integration, differentiating from generic Rollup plugins by handling Drupal's SDC structure. Works with Vite via Rollup options and targets Drupal module/theme bundlers.

npm install rollup-plugin-drupal-sdc-generator
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-DRUP
R
rollup-plugin-drupal-sdc-generator
devopsjavascriptv1.1.11
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'
const drupalSdcGenerator = require('rollup-plugin-drupal-sdc-generator')
Default export; ESM-only, CommonJS require will fail.
drupalSdcGenerator
import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'
import { drupalSdcGenerator } from 'rollup-plugin-drupal-sdc-generator'
Named import is incorrect; package uses default export only.
drupalSdcGenerator (Vite usage)
import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'; // in Vite config: export default defineConfig({ build: { rollupOptions: { plugins: [drupalSdcGenerator()] } } })
export default defineConfig({ plugins: [drupalSdcGenerator()] })
In Vite, the plugin must be inside rollupOptions.plugins, not top-level plugins.

Minimal Rollup configuration using the plugin with optional custom template directory.

import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'; export default { input: 'src/main.js', output: { dir: 'dist', format: 'iife', }, plugins: [ drupalSdcGenerator({ directory: 'templates', // optional: defaults to built-in templates }), ], };
Debug
Known issues
gotchaVite users must place the plugin inside `build.rollupOptions.plugins`, not in the top-level `plugins` array.
fix
Move plugin instantiation to `build.rollupOptions.plugins` in Vite config.
affects: all
gotchaTemplate directory defaults to the plugin's internal templates; if not customized, files may be missing or unwanted.
fix
Provide a `directory` option pointing to your own templates.
affects: all
gotchaPlaceholder `[name]` in template filenames and contents is replaced; use `\[name\]` for literal `[name]`.
fix
Escape with backslash: `\[name\]` to include literal `[name]`.
affects: all
gotchaPlugin is ESM-only; `require()` throws Module not found error.
fix
Use `import` syntax or dynamic `import()`.
affects: >=1.0.0
gotchaOnly one component can be generated per build unless using object `directory` option.
fix
Use object form of `directory` to map multiple component names to their template directories.
affects: all
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'rollup-plugin-drupal-sdc-generator'
Using CommonJS require() on an ESM-only package.
fix
Change to `import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'` and ensure your project is ESM (type: module in package.json or use .mjs extension).
Error: The plugin 'rollup-plugin-drupal-sdc-generator' is not a function
Using named import `{ drupalSdcGenerator }` instead of default import.
fix
Use `import drupalSdcGenerator from 'rollup-plugin-drupal-sdc-generator'` without curly braces.
For Vite: [plugin:vite:rollup] The plugin 'rollup-plugin-drupal-sdc-generator' is not a function
Plugin placed in Vite's top-level `plugins` instead of inside `build.rollupOptions.plugins`.
fix
Move the plugin inside `build.rollupOptions.plugins` array in your Vite config.
Upgrade
Version history
1.1.11latest on npm
Audit
Dependencies
rollupoptionalPlugin requires Rollup (or Vite's Rollup compatibility) to function; not a peer dependency but required at runtime.
viteoptionalOften used with Vite; not a direct dependency but expected in Vite projects.
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-drupal-sdc-generator — npm install rollup-plugin-drupal-sdc-generator · libregistry