template icon indicating copy to clipboard operation
template copied to clipboard

fix ts sourceMap warning on prod build

Open greenchapter opened this issue 4 years ago • 8 comments

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

greenchapter avatar Apr 29 '21 08:04 greenchapter

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 .

dummdidumm avatar Apr 29 '21 09:04 dummdidumm

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

greenchapter avatar Apr 29 '21 09:04 greenchapter

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?

dummdidumm avatar Apr 29 '21 09:04 dummdidumm

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?

Conduitry avatar Apr 29 '21 11:04 Conduitry

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 .

dummdidumm avatar Apr 29 '21 11:04 dummdidumm

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?

Conduitry avatar Apr 29 '21 12:04 Conduitry

@Conduitry @dummdidumm How can I support here?

greenchapter avatar May 06 '21 17:05 greenchapter

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.

dummdidumm avatar May 07 '21 09:05 dummdidumm