Skip to content

Commit

Permalink
cli: fix for type declarations being required even if not built
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
  • Loading branch information
Rugvip committed Mar 4, 2021
1 parent f6171e4 commit b93538a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-ravens-collect.md
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---

Fix for type declaration input being required for build even if types aren't being built.
32 changes: 16 additions & 16 deletions packages/cli/src/lib/builder/config.ts
Expand Up @@ -36,22 +36,6 @@ import { svgrTemplate } from '../svgrTemplate';
export const makeConfigs = async (
options: BuildOptions,
): Promise<RollupOptions[]> => {
const typesInput = paths.resolveTargetRoot(
'dist-types',
relativePath(paths.targetRoot, paths.targetDir),
'src/index.d.ts',
);

const declarationsExist = await fs.pathExists(typesInput);
if (!declarationsExist) {
const path = relativePath(paths.targetDir, typesInput);
throw new Error(
`No declaration files found at ${path}, be sure to run ${chalk.bgRed.white(
'yarn tsc',
)} to generate .d.ts files before packaging`,
);
}

const configs = new Array<RollupOptions>();

if (options.outputs.has(Output.cjs) || options.outputs.has(Output.esm)) {
Expand Down Expand Up @@ -112,6 +96,22 @@ export const makeConfigs = async (
}

if (options.outputs.has(Output.types)) {
const typesInput = paths.resolveTargetRoot(
'dist-types',
relativePath(paths.targetRoot, paths.targetDir),
'src/index.d.ts',
);

const declarationsExist = await fs.pathExists(typesInput);
if (!declarationsExist) {
const path = relativePath(paths.targetDir, typesInput);
throw new Error(
`No declaration files found at ${path}, be sure to run ${chalk.bgRed.white(
'yarn tsc',
)} to generate .d.ts files before packaging`,
);
}

configs.push({
input: typesInput,
output: {
Expand Down

0 comments on commit b93538a

Please sign in to comment.