{"id":13528374,"url":"https://github.com/ezolenko/rollup-plugin-typescript2","last_synced_at":"2025-05-14T16:03:23.786Z","repository":{"id":37271121,"uuid":"80691801","full_name":"ezolenko/rollup-plugin-typescript2","owner":"ezolenko","description":"Rollup plugin for typescript with compiler errors.","archived":false,"fork":false,"pushed_at":"2024-05-28T15:46:12.000Z","size":8999,"stargazers_count":825,"open_issues_count":23,"forks_count":70,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-03T02:08:27.065Z","etag":null,"topics":["rollup","rollup-plugin","rollup-plugin-typescript","rollup-plugin-typescript2","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ezolenko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-02T04:02:22.000Z","updated_at":"2025-03-10T18:01:16.000Z","dependencies_parsed_at":"2023-02-08T07:01:21.142Z","dependency_job_id":"975b7f6c-beeb-4b2c-a2e9-3275a719c17a","html_url":"https://github.com/ezolenko/rollup-plugin-typescript2","commit_stats":{"total_commits":454,"total_committers":33,"mean_commits":"13.757575757575758","dds":0.3612334801762115,"last_synced_commit":"f6db59613a66f58c48310aa8fa785951970b5d6d"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezolenko%2Frollup-plugin-typescript2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezolenko%2Frollup-plugin-typescript2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezolenko%2Frollup-plugin-typescript2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezolenko%2Frollup-plugin-typescript2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezolenko","download_url":"https://codeload.github.com/ezolenko/rollup-plugin-typescript2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154995,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rollup","rollup-plugin","rollup-plugin-typescript","rollup-plugin-typescript2","typescript"],"created_at":"2024-08-01T06:02:28.786Z","updated_at":"2025-04-10T03:49:05.243Z","avatar_url":"https://github.com/ezolenko.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","typescript","Plugins"],"sub_categories":["Transpilation"],"readme":"# rollup-plugin-typescript2\n\n[![npm-version](https://img.shields.io/npm/v/rollup-plugin-typescript2.svg?maxAge=259200)](https://npmjs.org/package/rollup-plugin-typescript2)\n[![npm-monthly-downloads](https://img.shields.io/npm/dm/rollup-plugin-typescript2.svg?maxAge=259200)](https://npmjs.org/package/rollup-plugin-typescript2)\n[![Node.js CI](https://github.com/ezolenko/rollup-plugin-typescript2/workflows/Node.js%20CI/badge.svg)](https://github.com/ezolenko/rollup-plugin-typescript2/actions?query=workflow%3A\"Node.js+CI\")\n\nRollup plugin for typescript with compiler errors.\n\nThis is a rewrite of the [original](https://github.com/rollup/rollup-plugin-typescript/tree/v0.8.1) `rollup-plugin-typescript`, starting and borrowing from [this fork](https://github.com/alexlur/rollup-plugin-typescript).\n\nThis version is somewhat slower than the original, but it will print out TypeScript syntactic and semantic diagnostic messages (the main reason for using TypeScript after all).\n\n## Installation\n\n```bash\n# with npm\nnpm install rollup-plugin-typescript2 typescript tslib --save-dev\n# with yarn\nyarn add rollup-plugin-typescript2 typescript tslib --dev\n```\n\n## Usage\n\n```js\n// rollup.config.js\nimport typescript from 'rollup-plugin-typescript2';\n\nexport default {\n\tinput: './main.ts',\n\n\tplugins: [\n\t\ttypescript(/*{ plugin options }*/)\n\t]\n}\n```\n\nThis plugin inherits all compiler options and file lists from your `tsconfig.json` file.\nIf your `tsconfig` has another name or another relative path from the root directory, see `tsconfigDefaults`, `tsconfig`, and `tsconfigOverride` options below.\nThis also allows for passing in different `tsconfig` files depending on your build target.\n\n### Some compiler options are forced\n\n* `noEmitHelpers`: false\n* `importHelpers`: true\n* `noResolve`: false\n* `noEmit`: false (Rollup controls emit)\n* `noEmitOnError`: false (Rollup controls emit. See [#254](https://github.com/ezolenko/rollup-plugin-typescript2/issues/254) and the `abortOnError` plugin option below)\n* `inlineSourceMap`: false (see [#71](https://github.com/ezolenko/rollup-plugin-typescript2/issues/71))\n* `outDir`: `./placeholder` in cache root (see [#83](https://github.com/ezolenko/rollup-plugin-typescript2/issues/83) and [Microsoft/TypeScript#24715](https://github.com/Microsoft/TypeScript/issues/24715))\n* `declarationDir`: Rollup's `output.file` or `output.dir` (*unless `useTsconfigDeclarationDir` is true in the plugin options*)\n* `allowNonTsExtensions`: true to let other plugins on the chain generate typescript; update plugin's `include` filter to pick them up (see [#111](https://github.com/ezolenko/rollup-plugin-typescript2/issues/111))\n\n### Some compiler options have more than one compatible value\n\n* `module`: defaults to `ES2015`. Other valid values are `ES2020`, `ES2022` and `ESNext` (required for dynamic imports, see [#54](https://github.com/ezolenko/rollup-plugin-typescript2/issues/54)).\n\n* `moduleResolution`: defaults to `node10` (same as `node`), but value from tsconfig is used if specified. Other valid (but mostly untested) values are `node16`, `nodenext` and `bundler`. If in doubt, use `node10`.\n\t* `classic` is [deprecated](https://www.typescriptlang.org/docs/handbook/module-resolution.html) and changed to `node10`. It also breaks this plugin, see [#12](https://github.com/ezolenko/rollup-plugin-typescript2/issues/12) and [#14](https://github.com/ezolenko/rollup-plugin-typescript2/issues/14).\n\n### Some options need additional configuration on plugin side\n\n* `allowJs`: lets TypeScript process JS files as well. If you use it, modify this plugin's `include` option to add `\"*.js+(|x)\", \"**/*.js+(|x)\"` (might also want to `exclude` `\"**/node_modules/**/*\"`, as it can slow down the build significantly).\n\n### Compatibility\n\n#### @rollup/plugin-node-resolve\n\nMust be before `rollup-plugin-typescript2` in the plugin list, especially when the `browser: true` option is used (see [#66](https://github.com/ezolenko/rollup-plugin-typescript2/issues/66)).\n\n#### @rollup/plugin-commonjs\n\nSee the explanation for `rollupCommonJSResolveHack` option below.\n\n#### @rollup/plugin-babel\n\nThis plugin transpiles code, but doesn't change file extensions. `@rollup/plugin-babel` only looks at code with these extensions [by default](https://github.com/rollup/plugins/tree/master/packages/babel#extensions): `.js,.jsx,.es6,.es,.mjs`. To workaround this, add `.ts` and `.tsx` to its list of extensions.\n\n```js\n// ...\nimport { DEFAULT_EXTENSIONS } from '@babel/core';\n// ...\n\tbabel({\n\t\textensions: [\n\t\t\t...DEFAULT_EXTENSIONS,\n\t\t\t'.ts',\n\t\t\t'.tsx'\n\t\t]\n\t}),\n// ...\n```\n\nSee [#108](https://github.com/ezolenko/rollup-plugin-typescript2/issues/108)\n\n### Plugin options\n\n* `cwd`: `string`\n\n\tThe current working directory. Defaults to `process.cwd()`.\n\n* `tsconfigDefaults`: `{}`\n\n\tThe object passed as `tsconfigDefaults` will be merged with the loaded `tsconfig.json`.\n\tThe final config passed to TypeScript will be the result of values in `tsconfigDefaults` replaced by values in the loaded `tsconfig.json`, replaced by values in `tsconfigOverride`, and then replaced by forced `compilerOptions` overrides on top of that (see above).\n\n\tFor simplicity and other tools' sake, try to minimize the usage of defaults and overrides and keep everything in a `tsconfig.json` file (`tsconfig`s can themselves be chained with [`extends`](https://www.typescriptlang.org/tsconfig#extends), so save some turtles).\n\n\t```js\n\tlet defaults = { compilerOptions: { declaration: true } };\n\tlet override = { compilerOptions: { declaration: false } };\n\n\t// ...\n\tplugins: [\n\t\ttypescript({\n\t\t\ttsconfigDefaults: defaults,\n\t\t\ttsconfig: \"tsconfig.json\",\n\t\t\ttsconfigOverride: override\n\t\t})\n\t]\n\t```\n\n\tThis is a [deep merge](https://lodash.com/docs/4.17.4#merge): objects are merged, arrays are merged by index, primitives are replaced, etc.\n\tIncrease `verbosity` to `3` and look for `parsed tsconfig` if you get something unexpected.\n\n* `tsconfig`: `undefined`\n\n\tPath to `tsconfig.json`.\n\tSet this if your `tsconfig` has another name or relative location from the project directory.\n\n\tBy default, will try to load `./tsconfig.json`, but will not fail if the file is missing, unless the value is explicitly set.\n\n* `tsconfigOverride`: `{}`\n\n\tSee `tsconfigDefaults`.\n\n* `check`: true\n\n\tSet to false to avoid doing any diagnostic checks on the code.\n\tSetting to false is sometimes referred to as `transpileOnly` by other TypeScript integrations.\n\n* `verbosity`: 1\n\n\t- 0 -- Error\n\t- 1 -- Warning\n\t- 2 -- Info\n\t- 3 -- Debug\n\n* `clean`: false\n\n\tSet to true to disable the cache and do a clean build.\n\tThis also wipes any existing cache.\n\n* `cacheRoot`: `node_modules/.cache/rollup-plugin-typescript2`\n\n\tPath to cache.\n\tDefaults to a folder in `node_modules`.\n\n* `include`: `[ \"*.ts+(|x)\", \"**/*.ts+(|x)\", \"**/*.cts\", \"**/*.mts\" ]`\n\n\tBy default compiles all `.ts` and `.tsx` files with TypeScript.\n\n* `exclude`: `[ \"*.d.ts\", \"**/*.d.ts\", \"**/*.d.cts\", \"**/*.d.mts\" ]`\n\n\tBut excludes type definitions.\n\n* `abortOnError`: true\n\n\tBail out on first syntactic or semantic error.\n\tIn some cases, setting this to false will result in an exception in Rollup itself (for example, unresolvable imports).\n\n* `rollupCommonJSResolveHack`: false\n\n\t_Deprecated_. OS native paths are now _always_ used since [`0.30.0`](https://github.com/ezolenko/rollup-plugin-typescript2/releases/0.30.0) (see [#251](https://github.com/ezolenko/rollup-plugin-typescript2/pull/251)), so this no longer has any effect -- as if it is always `true`.\n\n* `objectHashIgnoreUnknownHack`: false\n\n\tThe plugin uses your Rollup config as part of its cache key.\n\t`object-hash` is used to generate a hash, but it can have trouble with some uncommon types of elements.\n\tSetting this option to true will make `object-hash` ignore unknowns, at the cost of not invalidating the cache if ignored elements are changed.\n\n\tOnly enable this option if you need it (e.g. if you get `Error: Unknown object type \"xxx\"`) and make sure to run with `clean: true` once in a while and definitely before a release.\n\t(See [#105](https://github.com/ezolenko/rollup-plugin-typescript2/issues/105) and [#203](https://github.com/ezolenko/rollup-plugin-typescript2/pull/203))\n\n* `useTsconfigDeclarationDir`: false\n\n\tIf true, declaration files will be emitted in the [`declarationDir`](https://www.typescriptlang.org/tsconfig#declarationDir) given in the `tsconfig`.\n\tIf false, declaration files will be placed inside the destination directory given in the Rollup configuration.\n\n\tSet to false if any other Rollup plugins need access to declaration files.\n\n* `typescript`: peerDependency\n\n\tIf you'd like to use a different version of TS than the peerDependency, you can import a different TypeScript module and pass it in as `typescript: require(\"path/to/other/typescript\")`.\n\n\tYou can also use an alternative TypeScript implementation, such as [`ttypescript`](https://github.com/cevek/ttypescript), with this option.\n\n\tMust be TS 2.0+; things might break if the compiler interfaces changed enough from what the plugin was built against.\n\n* `transformers`: `undefined`\n\n\t**experimental**, TypeScript 2.4.1+\n\n\tTransformers will likely be available in `tsconfig` eventually, so this is not a stable interface (see [Microsoft/TypeScript#14419](https://github.com/Microsoft/TypeScript/issues/14419)).\n\n\tFor example, integrating [kimamula/ts-transformer-keys](https://github.com/kimamula/ts-transformer-keys):\n\n\t```js\n\tconst keysTransformer = require('ts-transformer-keys/transformer').default;\n\tconst transformer = (service) =\u003e ({\n  \t\tbefore: [ keysTransformer(service.getProgram()) ],\n  \t\tafter: []\n\t});\n\n\t// ...\n\tplugins: [\n\t\ttypescript({ transformers: [transformer] })\n\t]\n\t```\n\n### Declarations\n\nThis plugin respects [`declaration: true`](https://www.typescriptlang.org/tsconfig#declaration) in your `tsconfig.json` file.\nWhen set, it will emit `*.d.ts` files for your bundle.\nThe resulting file(s) can then be used with the `types` property in your `package.json` file as described [here](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html).\u003cbr /\u003e\nBy default, the declaration files will be located in the same directory as the generated Rollup bundle.\nIf you want to override this behavior and instead use [`declarationDir`](https://www.typescriptlang.org/tsconfig#declarationDir), set `useTsconfigDeclarationDir: true` in the plugin options.\n\nThe above also applies to [`declarationMap: true`](https://www.typescriptlang.org/tsconfig#declarationMap) and `*.d.ts.map` files for your bundle.\n\nThis plugin also respects [`emitDeclarationOnly: true`](https://www.typescriptlang.org/tsconfig#emitDeclarationOnly) and will only emit declarations (and declaration maps, if enabled) if set in your `tsconfig.json`.\nIf you use `emitDeclarationOnly`, you will need another plugin to compile any TypeScript sources, such as `@rollup/plugin-babel`, `rollup-plugin-esbuild`, `rollup-plugin-swc`, etc.\nWhen composing Rollup plugins this way, `rollup-plugin-typescript2` will perform type-checking and declaration generation, while another plugin performs the TypeScript to JavaScript compilation.\u003cbr /\u003e\nSome scenarios where this can be particularly useful: you want to use Babel plugins on TypeScript source, or you want declarations and type-checking for your Vite builds (**NOTE**: this space has not been fully explored yet).\n\n### Watch mode\n\nThe way TypeScript handles type-only imports and ambient types effectively hides them from Rollup's watch mode, because import statements are not generated and changing them doesn't trigger a rebuild.\n\nOtherwise the plugin should work in watch mode. Make sure to run a normal build after watch session to catch any type errors.\n\n### Requirements\n\n* TypeScript `2.4+`\n* Rollup `1.26.3+`\n* Node `6.4.0+` (basic ES6 support)\n\n### Reporting bugs and Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezolenko%2Frollup-plugin-typescript2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezolenko%2Frollup-plugin-typescript2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezolenko%2Frollup-plugin-typescript2/lists"}