Seamless integration between Rollup and Typescript.
npm install --save-dev rollup-plugin-typescript typescript tslib
Note that both
tslib are peer dependencies of this plugin that need to be installed separately.
// rollup.config.js;input: './main.ts'plugins:
The plugin loads any
compilerOptions from the
tsconfig.json file by default. Passing options to the plugin directly overrides those options:
The following options are unique to
options.exclude(each a minimatch pattern, or array of minimatch patterns), which determine which files are transpiled by Typescript (all
.tsxfiles by default).
tsconfigwhen set to false, ignores any options specified in the config file. If set to a string that corresponds to a file path, the specified file will be used as config file.
typescriptoverrides TypeScript used for transpilation:
tsliboverrides the injected TypeScript helpers with a custom version
Due to the use of
tslib to inject helpers, this plugin requires at least TypeScript 2.1. See also here.
Though it is not recommended, it is possible to configure this plugin to handle imports of CommonJS files from TypeScript. For this, you need to specify
CommonJS as the module format and add
rollup-plugin-commonjs to transpile the CommonJS output generated by TypeScript to ES Modules so that rollup can process it.
// rollup.config.js;;input: './main.ts'plugins:// the ".ts" extension is required
Note that this will often result in less optimal output.
This also causes issues with emit-less types, see #28.