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

[TypeScript] Include "js", "mjs", "cjs" and "json" in default includes #1663

Open
kraenhansen opened this issue Jan 15, 2024 · 1 comment
Open

Comments

@kraenhansen
Copy link

kraenhansen commented Jan 15, 2024

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: v11.0.0 through v11.1.6
  • Rollup Version: Tested plugin v11.0.0 with rollup@3.29.4 and plugin 11.1.6 with rollup@4.9.5.
  • 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 #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.

@foretoo
Copy link

foretoo commented Jan 29, 2024

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.

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

No branches or pull requests

2 participants