Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

fix ts sourceMap warning on prod build #241

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

greenchapter
Copy link

@greenchapter greenchapter commented Apr 29, 2021

This PR will change the following config

output: {sourcemap: true}
output: {sourcemap: !production}

It will remove the negation on sourceMap and removes the following warning:
(!) Plugin typescript: @rollup/plugin-typescript: Typescript 'sourceMap' compiler option must be set to generate source maps.

Fixes #174

@dummdidumm
Copy link
Member

Thanks, but this is the wrong fix, since this means there's not generation of source maps in dev mode anymore, where you arguably need them more. The right fix (I think, haven't tested it) would be to set this line to !production .

@greenchapter
Copy link
Author

Thanks, but this is the wrong fix, since this means there's not generation of source maps in dev mode anymore, where you arguably need them more. The right fix (I think, haven't tested it) would be to set this line to !production .

you are indeed right, I changed my Pull request to output: {sourcemap: !production}

With that it is fixed

@dummdidumm
Copy link
Member

Question remains if that is a desired default. I'd say yes because source maps are not of much use in production usually, but it is definetly a change other maintainers need to approve on. @Conduitry @antony thoughts?

@Conduitry
Copy link
Member

Disabling prod sourcemaps by default for the sake of this warning seems wrong. Regardless of whether we want to have them by default, if someone reenabled them, they'd be again faced with this warning.

What does this warning actually indicate? Is there something wrong with the produced sourcemaps? Is there some other setting that needs to be enabled?

@dummdidumm
Copy link
Member

The warning is a result of sourcemaps being disabled for TypeScript, while being enabled for Rollup as a whole. That's a mismatch and therefore it prints a warning - but it's not more than that, it will bundle. I think it would be nice to align the TS config for sourcemaps with that of the general rollup config though. So the alternative would be to set all these to true in the TS script instead of !production .

@Conduitry
Copy link
Member

Right, it'll bundle, but if TS sourcemaps are disabled, do the final sourcemaps only point back to the JS versions of everything? That seems like the real issue that should be addressed that the warning is telling us about.

Setting it to true in tsconfig.json sounds reasonable.

If we do want to make it dynamic at the TS step, can we pass in tsconfig overrides to the preprocessor and to the TypeScript compiler?

@greenchapter
Copy link
Author

@Conduitry @dummdidumm How can I support here?

@dummdidumm
Copy link
Member

I currently lean towards replacing all !production occurences in the TS script with true . That way people will always get the source maps (also when building for production, which matches the template without JS), and the user can still decide if he wants to upload those sourcemaps.

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

Successfully merging this pull request may close these issues.

Getting sourceMap warnning when run npm run build
3 participants