rollup-plugin-sham-ui-templates

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

Rollup plugin that compiles sham-ui template files (.sht, .sfc) during bundling. Version 1.1.0 is current. Supports two file types: standard templates and single-file components. Requires @rollup/plugin-babel for transformation. Minimal configuration; designed specifically for sham-ui projects.

error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
cause Using CommonJS require on an ESM-only package.
fix
Replace require() with import or set type: 'module' in package.json.
error TypeError: shamUICompiler is not a constructor
cause Using 'new' on a function export that is not a class.
fix
Remove 'new' and call shamUICompiler(...) directly.
gotcha Both .sht and .sfc must be added to Babel extensions for transformation.
fix Include extensions: ['.js', '.sht', '.sfc'] in @rollup/plugin-babel config.
gotcha Plugin is ESM-only; CommonJS require will fail with 'ERR_REQUIRE_ESM'.
fix Use import syntax or switch to an ESM-compatible environment.
gotcha Default export is a function, not a class; using 'new' will cause runtime error.
fix Call shamUICompiler(...) without 'new'.
deprecated No deprecated versions known.
npm install rollup-plugin-sham-ui-templates
yarn add rollup-plugin-sham-ui-templates
pnpm add rollup-plugin-sham-ui-templates

Shows Rollup configuration using two shamUICompiler instances for .sht and .sfc files, with Babel processing.

// rollup.config.js
import shamUICompiler from 'rollup-plugin-sham-ui-templates';
import { babel } from '@rollup/plugin-babel';

export default {
    input: 'src/main.js',
    output: {
        file: 'dist/bundle.js',
        format: 'iife',
        sourcemap: true
    },
    plugins: [
        shamUICompiler({
            extensions: ['.sht']
        }),
        shamUICompiler({
            extensions: ['.sfc'],
            compilerOptions: {
                asModule: false,
                asSingleFileComponent: true
            }
        }),
        babel({
            extensions: ['.js', '.sht', '.sfc'],
            exclude: ['node_modules/**'],
            babelHelpers: 'bundled'
        })
    ]
};