docs/package-metadata: document entry point fields

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-06-13 11:05:01 +02:00
parent ee8e016eee
commit 3ab55be3d8
+14
View File
@@ -37,3 +37,17 @@ If you are creating a module for an existing package that is not part of your pr
### `repository`
This field can be generated by the `backstage-cli repo fix --publish` command. The only requirement is that the `package.json` in your workspace root has the `repository` field documented.
### `main`
The main entry point of the package, pointing to the source file for development. This field along with other entry point fields such as `module` and `types` are rewritten when packaging the package for distribution. You can read more about this process in the [publishing](./cli/02-build-system.md#publishing) section, and it is also used for [backend production builds](./cli/02-build-system.md#backend-production).
### `exports`
The exports of the package, as defined by [Node.js](https://nodejs.org/api/packages.html#exports). This field is used to define the entry points of the package. As with other entry point fields, the exports should point to source files for development. They will the be rewritten when packaging the package for distribution. You can read more about this in the [sub-path exports](./cli/02-build-system.md#subpath-exports) section.
### `typeVersions`
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`.