Description
- Rollup Plugin Name: typescript
- Rollup Plugin Version: "@rollup/plugin-typescript": "^8.1.0",
- Rollup Version: "rollup": "^2.35.1",
- Operating System (or Browser): Ubuntu Focal Fossa
- Node Version: 14.4.0
- Link to reproduction (
⚠️ read below): https://github.com/cefn/testcase_rollup/tree/exclude-all
Expected Behavior
As defined in the Typescript Handbook I would expect the imports of a .ts input file to be compiled by the rollup typescript plugin regardless of whether their path was matched by include or exclude.
If the compiler identified a file as a target of a module import, it will be included in the compilation regardless if it was excluded in the previous steps.
https://www.typescriptlang.org/docs/handbook/module-resolution.html#why-does-a-module-in-the-exclude-list-still-get-picked-up-by-the-compiler
Actual Behavior
In the case that a file is set as input, (and listed in include), but its imports are not listed in the include list, this triggers an error. A workaround is to recursively identify all the imported files in the include list, but building your own logic for this almost defeats the purpose of a bundler. If you leave an imported .ts file out of the list, (see e.g. the comparison at https://github.com/cefn/testcase_rollup/compare/exclude-all ) then when rollup gets to trying to bundle those imported .ts files you get errors like...
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
If you try to set the rootDir to the project root and add **/*.ts
as the include parameter (ensuring anything is considered for transpilation during bundle), then in fact all .ts files in the whole project are transpiled, not just the ones referenced by the bundle.
Based on the handbook definitions, the rollup plugin interpretation what is 'included' in typescript compilation is not as expected. However, the feature proposed in #751 would be another way to fulfil the use case.