rollup-plugin-inline-ts

raw JSON →
1.0.6 verified Fri May 01 auth: no javascript

Rollup plugin that processes TypeScript code inside HTML `<script lang="ts">` tags, transpiling it to JavaScript using one of four engines: oxc (default), swc, esbuild, or the TypeScript compiler. Version 1.0.6 requires Node.js >=18 and supports Rollup 1–4. Unlike full-featured build plugins (e.g., @rollup/plugin-typescript), this performs no type checking, focusing solely on transpilation. Ships TypeScript declarations. Release cadence is irregular; last update June 2025.

error Cannot find module 'oxc-transform'
cause Default engine is oxc, but oxc-transform is not installed.
fix
Run 'npm install oxc-transform --save-dev' or set a different engine (e.g., engine: 'swc').
error The requested module 'rollup-plugin-inline-ts' does not provide an export named 'inlineTs'
cause Mistakenly using named import instead of default import.
fix
Use 'import inlineTs from 'rollup-plugin-inline-ts'' (default import).
error Unexpected token 'export'
cause The plugin outputs ESM code; if your Rollup config uses CommonJS (require), it may not handle ESM correctly.
fix
Ensure rollup.config.js uses ESM (e.g., type: 'module' in package.json) or use .mjs extension.
breaking Node.js version requirement is >=18 (v1.0.6). Earlier versions may fail with ESM imports.
fix Upgrade Node.js to >=18 or use an older version of the plugin (e.g., 0.x) if needed.
breaking Default engine changed from 'swc' to 'oxc' in v1.0.0. Existing configurations relying on swc may silently fail if oxc-transform is not installed.
fix Explicitly set engine: 'swc' and install @swc/core, or install oxc-transform.
deprecated The 'target' option for the TypeScript engine is deprecated; use 'options' object instead.
fix Pass compiler options via the 'options' field: inlineTs({ engine: 'typescript', options: { target: 'ESNext' } })
gotcha Plugin does NOT perform type checking. TypeScript errors in <script lang='ts'> blocks will not be reported during build.
fix Run tsc separately or use a type-checking plugin like @rollup/plugin-typescript alongside.
npm install rollup-plugin-inline-ts
yarn add rollup-plugin-inline-ts
pnpm add rollup-plugin-inline-ts

Shows basic Rollup config using the plugin with the default oxc engine and custom extensions.

import inlineTs from 'rollup-plugin-inline-ts';

export default {
  input: 'src/index.html',
  plugins: [
    inlineTs({
      engine: 'oxc',
      extensions: ['.html', '.xht'],
    }),
  ],
  output: {
    dir: 'dist',
    format: 'esm',
  },
};