paularmstrong / build-tracker

A set of tools to track the size of your build artifacts over time.
https://buildtracker.dev
MIT License
439 stars 27 forks source link

[fix] Export TS declaration files #162

Closed paularmstrong closed 4 years ago

paularmstrong commented 4 years ago

Problem

(From #105, per @OliverJAsh ) The types field in the package.json of @build-tracker/plugin-with-postgres currently refers to the TS source code:

https://github.com/paularmstrong/build-tracker/blob/f66274bba0003e58cd2922b759cc883222e21ac9/plugins/with-postgres/package.json#L10

This means that TS users who import from this module will get lots of errors relating to the source code.

It would be better if the types field instead just referred to some declaration files (.d.ts). These could be generated using the declaration compiler option. This way, users will only import the types—they won't be forced to type check the actual source code itself.

Solution

Using declarations: true in the root tsconfig.json seems to ensure the declaration files are built, but references in the monorepo seem to keep up-to-date with what is in the src folder for each workspace, thanks to the "module": "./" in each package.json and the root index.ts file referencing the src directory.

This presented a small problem in that we want to make sure that file isn't included in the build. I've also added files: ['dist', 'index.js'] to each (appropriate) package.json.

It looks like publishing works as expected

Screen Shot 2020-03-15 at 8 24 44 AM

Fixes #105 Closes #117, #118

TODO

github-actions[bot] commented 4 years ago

⚠️: Group "Web App" failed the gzip budget size limit of 150 KiB by 2.89 KiB

View table | | 31f1615 | b1c5431 | Δ1 | | :------ | ---------: | ---------: | -----------------: | | All | 474.39 KiB | 474.52 KiB | 0.13 KiB (0.0%) | | Web App | 152.86 KiB | 152.89 KiB | ⚠️ 0.03 KiB (0.0%) |

View on Build Tracker

OliverJAsh commented 4 years ago

Thank you for doing this! ❤️