Seamless integration between Rollup and TypeScript with comprehensive error reporting.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Rollup plugin for TypeScript with comprehensive error reporting and diagnostic capabilities. This is a rewrite of the original rollup-plugin-typescript that provides seamless integration between Rollup and TypeScript while displaying TypeScript syntactic and semantic diagnostic messages during the build process.
npm install rollup-plugin-typescript2 typescript tslib --save-dev// Default export - main plugin function
import typescript from 'rollup-plugin-typescript2';
// Named export - options type
import { RPT2Options } from 'rollup-plugin-typescript2';
// Combined import
import typescript, { RPT2Options } from 'rollup-plugin-typescript2';For CommonJS:
// Default export
const typescript = require('rollup-plugin-typescript2');
// Destructured named export
const { RPT2Options } = require('rollup-plugin-typescript2');// rollup.config.js
import typescript from 'rollup-plugin-typescript2';
export default {
input: './main.ts',
plugins: [
typescript({
// Plugin options (all optional)
check: true, // Enable type checking
verbosity: 1, // 0=Error, 1=Warning, 2=Info, 3=Debug
clean: false, // Clean build cache
tsconfig: undefined, // Path to tsconfig.json
useTsconfigDeclarationDir: false, // Use tsconfig declarationDir
// ... other options
})
],
output: {
file: 'dist/bundle.js',
format: 'es'
}
};Rollup Plugin TypeScript2 is built around several core components:
Core plugin setup and configuration options for integrating TypeScript compilation into Rollup builds.
/**
* Main plugin function that creates a Rollup plugin instance (default export)
* @param options - Plugin configuration options
* @returns Rollup plugin instance
*/
export default function typescript(options?: RPT2Options): Plugin;
/**
* Type alias for plugin options (named export)
*/
export type RPT2Options = Partial<IOptions>;TypeScript compiler integration with language service, diagnostics, and type checking capabilities.
interface IOptions {
cwd: string;
check: boolean;
verbosity: VerbosityLevel;
typescript: typeof import('typescript');
tsconfig?: string;
tsconfigOverride: any;
tsconfigDefaults: any;
}File filtering, caching, and transformation system for handling TypeScript source files.
interface IOptions {
include: string | string[];
exclude: string | string[];
clean: boolean;
cacheRoot: string;
abortOnError: boolean;
}Experimental support for TypeScript transformers to modify the compilation process.
import * as tsTypes from 'typescript';
interface ICustomTransformer {
before?: tsTypes.TransformerFactory<tsTypes.SourceFile>;
after?: tsTypes.TransformerFactory<tsTypes.SourceFile>;
afterDeclarations?: tsTypes.TransformerFactory<tsTypes.Bundle | tsTypes.SourceFile>;
}
type TransformerFactoryCreator = (ls: tsTypes.LanguageService) => tsTypes.CustomTransformers | ICustomTransformer;Verbosity control and diagnostic message reporting system.
import { PluginContext } from 'rollup';
enum VerbosityLevel {
Error = 0,
Warning = 1,
Info = 2,
Debug = 3
}
class RollupContext {
constructor(verbosity: VerbosityLevel, bail: boolean, context: PluginContext, prefix?: string);
warn(message: string | (() => string)): void;
error(message: string | (() => string)): void | never;
info(message: string | (() => string)): void;
debug(message: string | (() => string)): void;
}import { Plugin, PluginContext } from 'rollup';
import * as tsTypes from 'typescript';
interface IOptions {
cwd: string;
include: string | string[];
exclude: string | string[];
check: boolean;
verbosity: VerbosityLevel;
clean: boolean;
cacheRoot: string;
abortOnError: boolean;
rollupCommonJSResolveHack: boolean;
tsconfig?: string;
useTsconfigDeclarationDir: boolean;
typescript: typeof import('typescript');
tsconfigOverride: any;
transformers: TransformerFactoryCreator[];
tsconfigDefaults: any;
sourceMapCallback: (id: string, map: string) => void;
objectHashIgnoreUnknownHack: boolean;
}
type RPT2Options = Partial<IOptions>;
enum VerbosityLevel {
Error = 0,
Warning = 1,
Info = 2,
Debug = 3
}
interface ICustomTransformer {
before?: tsTypes.TransformerFactory<tsTypes.SourceFile>;
after?: tsTypes.TransformerFactory<tsTypes.SourceFile>;
afterDeclarations?: tsTypes.TransformerFactory<tsTypes.Bundle | tsTypes.SourceFile>;
}
type TransformerFactoryCreator = (ls: tsTypes.LanguageService) => tsTypes.CustomTransformers | ICustomTransformer;
class RollupContext {
constructor(verbosity: VerbosityLevel, bail: boolean, context: PluginContext, prefix?: string);
warn(message: string | (() => string)): void;
error(message: string | (() => string)): void | never;
info(message: string | (() => string)): void;
debug(message: string | (() => string)): void;
}