[TypeScript] Include "js", "mjs", "cjs" and "json" in default `includes`
- Rollup Plugin Name:
@rollup/plugin-typescript - Rollup Plugin Version:
v11.0.0throughv11.1.6 - Rollup Version: Tested plugin
v11.0.0with[email protected]and plugin11.1.6with[email protected]. - Operating System (or Browser): MacOS
- Node Version: v20.10.0
- Link to reproduction (⚠️ read below): https://github.com/kraenhansen/rollup-plugin-typescript-issue-1663
Expected Behavior
Between v10.0.1 and v11.0.0 of the @rollup/plugin-typescript package, what I suspect is the merge of https://github.com/rollup/plugins/issues/1267 regressed a feature that I was relying on.
When resolving files through the paths of a tsconfig.json, I expect .js, .cjs, .mjs and .json files to resolve, just as if they're referenced directly using relative paths in a TypeScript source file.
Actual Behavior
When resolving files through the paths of a tsconfig.json the files are externalised from the bundle.
Additional Information
The issue can be worked around by providing a value for the includes option, which includes the extensions of all the expected files: '{,**/}*.(cts|mts|ts|tsx|js|cjs|mjs|json)'. This issue might simply be a case of a misalignment in my expectations of the default and the actual default. If there's no immediate drawback, I'd suggest expanding this default value for includes to include any file extension importable from TypeScript. Alternatively, the default could be determined based on the value of the allowJs resolveJsonModule options from the loaded tsconfig.json.
As a side-note: Adding to the confusion, is that the plugin uses "includes" as the name for this option, which can easily be confused with a way to supply and alternative / overriding value for the TypeScript includes option read from the tsconfig.json. This is most likely why I originally didn't think to configure it.
it took me 2 days to find a reason why paths in .js files are not trasformed, i even wrote my own transformer to handle it, lol.