From 013449b98a29f6e5a5953a80e0f24c64c01efa35 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 13 Jun 2024 11:51:24 +0200 Subject: [PATCH] docs/package-metadata: document sideEffects field Signed-off-by: Patrik Oldsberg --- docs/tooling/package-metadata.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/tooling/package-metadata.md b/docs/tooling/package-metadata.md index e5bd2b55cf..f3ffe6986e 100644 --- a/docs/tooling/package-metadata.md +++ b/docs/tooling/package-metadata.md @@ -51,3 +51,9 @@ The exports of the package, as defined by [Node.js](https://nodejs.org/api/packa This field is used to specify the type entry points for the package, the TypeScript equivalent of the `exports` field. TypeScript also supports defining this in the `exports` field, but that requires that the `moduleResolution` option in `tsconfig.json` is set to `node16` or `bundler`, which we currently do not support. This field can be generated by the `backstage-cli repo fix` command. First fill out the `exports` field to point to source fields, which will then be used to generate the `typeVersions`. + +### `sideEffects` + +This field declares whether it is safe to remove unused code when bundling this package into a frontend build, and is defined for example by [WebPack](https://github.com/backstage/backstage/blob/8d5cdb5d536cc8eb444da4b57dca4e36716f4535/plugins/auth-backend-module-google-provider/config.d.ts#L22). + +This field can be generated by the `backstage-cli repo fix` command. It will set to `false` by default for all frontend packages, since Backstage frontend packages should generally never have any side effects. If your package does have side effects, you can set explicitly set this field to `true`.