Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup plugin Exclude and Include behaviours don't align with Typescript #753

Closed
cefn opened this issue Jan 1, 2021 · 2 comments
Closed

Comments

@cefn
Copy link

cefn commented Jan 1, 2021

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.

Additional Information

@shellscape
Copy link
Collaborator

Thanks for the issue. This isn't one we've heard complaints for before, but I could see how the longer compilations might be a problem in very large codebases. Please do consider submitting a PR for this one. Given the low interest I'm not sure one of the plugin's maintainers will make time to pick it up.

@shellscape
Copy link
Collaborator

I just ran across #747, which appears to be identical. Since that was the first issue we received, we'll give that one priority. Please do continue discussion on that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants