diff --git a/.changeset/chilly-books-sneeze.md b/.changeset/chilly-books-sneeze.md new file mode 100644 index 0000000000..a2d3ca1e04 --- /dev/null +++ b/.changeset/chilly-books-sneeze.md @@ -0,0 +1,6 @@ +--- +'@backstage/cli-node': minor +'@backstage/cli': minor +--- + +Removed support for the `publishConfig.alphaTypes` and `.betaTypes` fields that were used together with `--experimental-type-build` to generate `/alpha` and `/beta` entry points. Use the `exports` field to achieve this instead. diff --git a/packages/cli-node/api-report.md b/packages/cli-node/api-report.md index 91148596b3..71be6c4bd4 100644 --- a/packages/cli-node/api-report.md +++ b/packages/cli-node/api-report.md @@ -53,8 +53,6 @@ export interface BackstagePackageJson { access?: 'public' | 'restricted'; directory?: string; registry?: string; - alphaTypes?: string; - betaTypes?: string; }; // (undocumented) scripts?: { diff --git a/packages/cli-node/src/monorepo/PackageGraph.ts b/packages/cli-node/src/monorepo/PackageGraph.ts index 421c49f9b9..fb46dbde26 100644 --- a/packages/cli-node/src/monorepo/PackageGraph.ts +++ b/packages/cli-node/src/monorepo/PackageGraph.ts @@ -56,8 +56,6 @@ export interface BackstagePackageJson { access?: 'public' | 'restricted'; directory?: string; registry?: string; - alphaTypes?: string; - betaTypes?: string; }; dependencies?: { diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index aea5df649a..6a59924a30 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -23,7 +23,7 @@ import { readEntryPoints } from '../entryPoints'; const PKG_PATH = 'package.json'; const PKG_BACKUP_PATH = 'package.json-prepack'; -const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; +const SKIPPED_KEYS = ['access', 'registry', 'tag']; const SCRIPT_EXTS = ['.js', '.jsx', '.ts', '.tsx']; interface ProductionPackOptions { @@ -42,14 +42,6 @@ export async function productionPack(options: ProductionPackOptions) { await fs.writeFile(PKG_BACKUP_PATH, pkgContent); } - const hasStageEntry = - !!pkg.publishConfig?.alphaTypes || !!pkg.publishConfig?.betaTypes; - if (pkg.exports && hasStageEntry) { - throw new Error( - 'Combining both exports and alpha/beta types is not supported', - ); - } - // This mutates pkg to fill in index exports, so call it before applying publishConfig const writeCompatibilityEntryPoints = await prepareExportsEntryPoints( pkg, @@ -99,12 +91,6 @@ export async function productionPack(options: ProductionPackOptions) { await fs.writeJson(pkgPath, pkg, { encoding: 'utf8', spaces: 2 }); } - if (publishConfig.alphaTypes) { - await writeReleaseStageEntrypoint(pkg, 'alpha', targetDir ?? packageDir); - } - if (publishConfig.betaTypes) { - await writeReleaseStageEntrypoint(pkg, 'beta', targetDir ?? packageDir); - } if (writeCompatibilityEntryPoints) { await writeCompatibilityEntryPoints(targetDir ?? packageDir); } @@ -118,12 +104,6 @@ export async function revertProductionPack(packageDir: string) { // Check if we're shipping types for other release stages, clean up in that case const pkg = await fs.readJson(PKG_PATH); - if (pkg.publishConfig?.alphaTypes) { - await fs.remove(resolvePath(packageDir, 'alpha')); - } - if (pkg.publishConfig?.betaTypes) { - await fs.remove(resolvePath(packageDir, 'beta')); - } // Remove any extra entrypoint backwards compatibility directories const entryPoints = readEntryPoints(pkg); @@ -140,32 +120,6 @@ export async function revertProductionPack(packageDir: string) { } } -function resolveEntrypoint(pkg: any, name: string) { - const targetEntry = pkg.publishConfig[name] || pkg[name]; - return targetEntry && posixPath.join('..', targetEntry); -} - -// Writes e.g. alpha/package.json -async function writeReleaseStageEntrypoint( - pkg: BackstagePackageJson, - stage: 'alpha' | 'beta', - targetDir: string, -) { - await fs.ensureDir(resolvePath(targetDir, stage)); - await fs.writeJson( - resolvePath(targetDir, stage, PKG_PATH), - { - name: pkg.name, - version: pkg.version, - main: resolveEntrypoint(pkg, 'main'), - module: resolveEntrypoint(pkg, 'module'), - browser: resolveEntrypoint(pkg, 'browser'), - types: posixPath.join('..', pkg.publishConfig![`${stage}Types`]!), - }, - { encoding: 'utf8', spaces: 2 }, - ); -} - const EXPORT_MAP = { import: '.esm.js', require: '.cjs.js',