switch to explicit require for lazy-loading dependencies in node packages
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/backend-test-utils': patch
|
||||
'@backstage/backend-defaults': patch
|
||||
'@backstage/config-loader': patch
|
||||
---
|
||||
|
||||
Internal refactor to use explicit `require` for lazy-loading dependency.
|
||||
@@ -103,7 +103,7 @@ export async function buildPgDatabaseConfig(
|
||||
Connector: CloudSqlConnector,
|
||||
IpAddressTypes,
|
||||
AuthTypes,
|
||||
} = await import('@google-cloud/cloud-sql-connector');
|
||||
} = require('@google-cloud/cloud-sql-connector') as typeof import('@google-cloud/cloud-sql-connector');
|
||||
const connector = new CloudSqlConnector();
|
||||
const clientOpts = await connector.getOptions({
|
||||
instanceConnectionName: config.connection.instance,
|
||||
|
||||
+2
-1
@@ -59,7 +59,8 @@ export async function startMemcachedContainer(
|
||||
image: string,
|
||||
): Promise<Instance> {
|
||||
// Lazy-load to avoid side-effect of importing testcontainers
|
||||
const { GenericContainer } = await import('testcontainers');
|
||||
const { GenericContainer } =
|
||||
require('testcontainers') as typeof import('testcontainers');
|
||||
|
||||
const container = await new GenericContainer(image)
|
||||
.withExposedPorts(11211)
|
||||
|
||||
+2
-1
@@ -57,7 +57,8 @@ export async function connectToExternalRedis(
|
||||
|
||||
export async function startRedisContainer(image: string): Promise<Instance> {
|
||||
// Lazy-load to avoid side-effect of importing testcontainers
|
||||
const { GenericContainer } = await import('testcontainers');
|
||||
const { GenericContainer } =
|
||||
require('testcontainers') as typeof import('testcontainers');
|
||||
|
||||
const container = await new GenericContainer(image)
|
||||
.withExposedPorts(6379)
|
||||
|
||||
@@ -72,7 +72,8 @@ export async function startMysqlContainer(image: string): Promise<{
|
||||
const password = uuid();
|
||||
|
||||
// Lazy-load to avoid side-effect of importing testcontainers
|
||||
const { GenericContainer } = await import('testcontainers');
|
||||
const { GenericContainer } =
|
||||
require('testcontainers') as typeof import('testcontainers');
|
||||
|
||||
const container = await new GenericContainer(image)
|
||||
.withExposedPorts(3306)
|
||||
|
||||
@@ -72,7 +72,8 @@ export async function startPostgresContainer(image: string): Promise<{
|
||||
const password = uuid();
|
||||
|
||||
// Lazy-load to avoid side-effect of importing testcontainers
|
||||
const { GenericContainer } = await import('testcontainers');
|
||||
const { GenericContainer } =
|
||||
require('testcontainers') as typeof import('testcontainers');
|
||||
|
||||
const container = await new GenericContainer(image)
|
||||
.withExposedPorts(5432)
|
||||
|
||||
@@ -164,9 +164,8 @@ async function compileTsSchemas(paths: string[]) {
|
||||
|
||||
// Lazy loaded, because this brings up all of TypeScript and we don't
|
||||
// want that eagerly loaded in tests
|
||||
const { getProgramFromFiles, buildGenerator } = await import(
|
||||
'typescript-json-schema'
|
||||
);
|
||||
const { getProgramFromFiles, buildGenerator } =
|
||||
require('typescript-json-schema') as typeof import('typescript-json-schema');
|
||||
|
||||
const program = getProgramFromFiles(paths, {
|
||||
incremental: false,
|
||||
|
||||
Reference in New Issue
Block a user