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

Warning should not be shown on rollup.config.ts about sourcemaps #1805

Open
TenPotatoes opened this issue Oct 29, 2024 · 3 comments
Open

Warning should not be shown on rollup.config.ts about sourcemaps #1805

TenPotatoes opened this issue Oct 29, 2024 · 3 comments

Comments

@TenPotatoes
Copy link

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 12.1.0

Expected Behavior / Situation

I don't get a sourcemap warning message about rollup.config.ts.

Actual Behavior / Situation

When I run rollup with rollup.config.ts, it uses my tsconfig.json which has sourcemap: true because I want sourcemaps, and it gives me an error @rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.

I think my only option to get the warning to go away is to use tsconfig.json for rollup.config.ts only, and use another name like tsconfig.project.json for my actual project.

Modification Proposal

Options:

  1. Turn this warning off for rollup.config.ts
  2. Allow passing in a different tsconfig via https://rollupjs.org/command-line-interface/#configplugin-plugin
  3. Default the tsconfig options for this file instead of using my project's tsconfig.

More context:

https://rollupjs.org/command-line-interface/#configplugin-plugin

#216 (comment)

You are not getting this error from the build but from transpiling the config file: loaded rollup.config.ts with warnings

Make sure to remove the sourceMap option from your tsconfig.json!

@lukastaegert
Copy link
Member

lukastaegert commented Oct 30, 2024

While it is still not super nice, you can pass in plugin options as well via the command line, and this includes compiler options. So something like this should actually work:

rollup --config rollup.config.ts --configPlugin 'typescript={compilerOptions:{sourceMap:false}}'

This is documented:

This option supports the same syntax as the --plugin option i.e., you can specify the option multiple times, you can omit the @rollup/plugin- prefix and just write typescript and you can specify plugin options via ={...}.

But I agree that it would better if this was not necessary. The best solution I can see so far would be to detect specifically the default names of config files in the plugin.

@TenPotatoes
Copy link
Author

I tried it and it does get rid of the error and I do still see sourcemaps in my output.

I'm not sure why it works though - why does the passed in compilerOptions apply to transpiling the rollup.config.ts and not to the rest of the project? I would have expected it to apply to the project itself. So I don't think this solution is discoverable from the current doc.

detect specifically the default names of config files in the plugin.

Sounds perfect if it's just to turn off the warning in that case

@lukastaegert
Copy link
Member

I'm not sure why it works though - why does the passed in compilerOptions apply to transpiling the rollup.config.ts and not to the rest of the project?

The configuration is transpiled with a completely separate Rollup run orchestrated by the CLI. I just tried it and again, what I wrote above solved the issue for me. You can still get an error from your regular run, though, which you should fix by specifying the sourcemap option as the error suggests, e.g.

rollup --config rollup.config.ts --configPlugin 'typescript={compilerOptions:{sourceMap:false}}' --sourcemap

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