Thoth.Json icon indicating copy to clipboard operation
Thoth.Json copied to clipboard

Fix path when auto decoding unions

Open alfonsogarciacaro opened this issue 4 years ago • 3 comments

I realized that, when using an autodecoder for unions and there's an error in one of the fields, the index of the field is not shown in the path which makes it more difficult to spot the problem. This fixes it.

I also took the chance to add a package.json in this PR with the sideEffects field set to false. In principle this should enable better tree shaking for Thoth.Json files.

alfonsogarciacaro avatar Sep 17 '21 01:09 alfonsogarciacaro

Thank you Alfonso.

How is the sideEffects taking place ?

I mean Fable is the one responsible to compile the Thoth.Json library so I don't think webpack or any other bundler with see the package.json right ?

MangelMaxime avatar Sep 17 '21 07:09 MangelMaxime

Fable compiles the F# files to JS and puts them together with other contents of the library (maybe js, css or in this case a package.json) in a directory within the .fable folder (which will be placed in outDir if set). Then the bundler kicks in and, at least webpack, if it detects the package.json with sideEffects: fals in that folder it will tree shake the files more aggressively. We added it recently for fable-library and it seems it helps a lot in reducing the output.

alfonsogarciacaro avatar Sep 17 '21 07:09 alfonsogarciacaro

I see, thank you for the explanations :)

MangelMaxime avatar Sep 17 '21 07:09 MangelMaxime