Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backstage field to export in package.json #26524

Merged
merged 12 commits into from
Sep 23, 2024
Merged

Conversation

HHogg
Copy link
Member

@HHogg HHogg commented Sep 6, 2024

This adds a step to the prepack command that will add an additional "backstage" metadata field to exports which provides information on the default export of the Backstage package.

{ 
  "exports": {
    ".": {
      "require": "./dist/index.cjs.js",
      "types": "./dist/index.d.ts",
      "default": "./dist/index.cjs.js"
    },
    "./alpha": {
      "require": "./dist/alpha.cjs.js",
      "types": "./dist/alpha.d.ts",
      "default": "./dist/alpha.cjs.js",
      "backstage": "@backstage/BackendFeature" <------ New field
    },
    "./package.json": "./package.json"
  },
}

The way it extracts the information is to use ts-morph which works the same way as the typescript server does for IDEs and uses the compiler to build up references and resolves types so we can avoid having to traverse the AST to look for type information.

@github-actions github-actions bot added area:catalog Related to the Catalog Project Area area:techdocs Related to the TechDocs Project Area area:kubernetes Related to the Kubernetes Project Area - not deploying Backstage with k8s. search Things related to Search homepage Features for the composable homepage area:scaffolder Everything and all things related to the scaffolder project area area:permission Related to the Permission Project Area area:events Related to the Events Project Area area:home area:search labels Sep 6, 2024
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Sep 6, 2024

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/cli packages/cli patch v0.27.1

@backstage-goalie
Copy link
Contributor

Thanks for the contribution!
All commits need to be DCO signed before they are reviewed. Please refer to the the DCO section in CONTRIBUTING.md or the DCO status for more info.

@HHogg HHogg force-pushed the hhogg/dynamic-metadata branch 2 times, most recently from 77668c4 to 5807f75 Compare September 9, 2024 14:36
@HHogg HHogg changed the title Add exports field to Backstage metadata in package.json Add features field to Backstage metadata in package.json Sep 9, 2024
@HHogg HHogg force-pushed the hhogg/dynamic-metadata branch 4 times, most recently from fc48e17 to 397ab03 Compare September 11, 2024 11:05
@HHogg HHogg marked this pull request as ready for review September 11, 2024 11:09
@HHogg HHogg requested review from a team and awanlin as code owners September 11, 2024 11:09
@github-actions github-actions bot removed area:permission Related to the Permission Project Area area:events Related to the Events Project Area area:home area:search labels Sep 12, 2024
@HHogg HHogg force-pushed the hhogg/dynamic-metadata branch 2 times, most recently from 35e21b8 to c6cb2d1 Compare September 12, 2024 16:35
Added a fixer step to the backstage-cli fix command that will annotate default export features to the package json backstage metadata

Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
@HHogg HHogg force-pushed the hhogg/dynamic-metadata branch from c6cb2d1 to fd8128c Compare September 16, 2024 11:33
@HHogg HHogg changed the title Add features field to Backstage metadata in package.json Add backstage field to export in package.json Sep 16, 2024
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I think we're about ready to ship 😎

Just a couple of minor bits

packages/cli/src/lib/typeDistProject.ts Outdated Show resolved Hide resolved
packages/cli/src/lib/packager/productionPack.ts Outdated Show resolved Hide resolved
packages/cli/src/lib/typeDistProject.ts Outdated Show resolved Hide resolved
packages/cli/src/lib/typeDistProject.ts Outdated Show resolved Hide resolved
packages/cli/src/lib/typeDistProject.ts Outdated Show resolved Hide resolved
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
Signed-off-by: Harrison Hogg <hhogg@spotify.com>
@HHogg HHogg force-pushed the hhogg/dynamic-metadata branch from e97b771 to 0b2794a Compare September 23, 2024 11:46
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, let's :shipit:! 👍

Love how slim we ended up getting this in the end 🎉

@HHogg HHogg merged commit c576a36 into master Sep 23, 2024
29 checks passed
@HHogg HHogg deleted the hhogg/dynamic-metadata branch September 23, 2024 12:32
Copy link
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.32.0 release, scheduled for Tue, 15 Oct 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants