cli: fix local dev entry points

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-02-22 18:42:00 +01:00
parent f16d9f31cd
commit 1ad8d885d3
2 changed files with 13 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Fixed a bug where additional backend package entry points where not properly marked as internal during local development.
+8 -3
View File
@@ -15,7 +15,7 @@
*/
import fs from 'fs-extra';
import { resolve as resolvePath } from 'path';
import { resolve as resolvePath, join as joinPath } from 'path';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ModuleScopePlugin from 'react-dev-utils/ModuleScopePlugin';
@@ -36,6 +36,8 @@ import { runPlain } from '../run';
import ESLintPlugin from 'eslint-webpack-plugin';
import pickBy from 'lodash/pickBy';
import yn from 'yn';
import { readEntryPoints } from '../monorepo/entryPoints';
import { ExtendedPackage } from '../monorepo';
const BUILD_CACHE_ENV_VAR = 'BACKSTAGE_CLI_EXPERIMENTAL_BUILD_CACHE';
@@ -232,7 +234,10 @@ export async function createBackendConfig(
// Find all local monorepo packages and their node_modules, and mark them as external.
const { packages } = await getPackages(cliPaths.targetDir);
const localPackageNames = packages.map(p => p.packageJson.name);
const localPackageEntryPoints = packages.flatMap(p => {
const entryPoints = readEntryPoints((p as ExtendedPackage).packageJson);
return entryPoints.map(e => joinPath(p.packageJson.name, e.mount));
});
const moduleDirs = packages.map(p => resolvePath(p.dir, 'node_modules'));
// See frontend config
const externalPkgs = packages.filter(p => !isChildPath(paths.root, p.dir));
@@ -261,7 +266,7 @@ export async function createBackendConfig(
nodeExternalsWithResolve({
modulesDir: paths.rootNodeModules,
additionalModuleDirs: moduleDirs,
allowlist: ['webpack/hot/poll?100', ...localPackageNames],
allowlist: ['webpack/hot/poll?100', ...localPackageEntryPoints],
}),
],
target: 'node' as const,