Skip to content

Commit d8266f5

Browse files
committed
private and improve bundle.mjs
1 parent eec20b7 commit d8266f5

File tree

11 files changed

+42
-27
lines changed

11 files changed

+42
-27
lines changed

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ export * from './io-host';
22
export * from './io-message';
33
export * from './toolkit-action';
44
export * from './payloads';
5-
export * from './messages';

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-activity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { type MetadataEntry } from '@aws-cdk/cloud-assembly-schema';
2-
import { type CloudFormationStackArtifact } from '@aws-cdk/cx-api';
1+
import type { MetadataEntry } from '@aws-cdk/cloud-assembly-schema';
2+
import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
33
import type { StackEvent } from '@aws-sdk/client-cloudformation';
44
import type { StackProgress } from './progress';
55

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/watch.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* The computed file watch settings
43
*/

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export * from './io-helper';
22
export * from './level-priority';
33
export * from './marker';
44
export * from './message-maker';
5+
export * from './messages';
56
export * from './types';

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/messages.ts renamed to packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/messages.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import type * as cxapi from '@aws-cdk/cx-api';
2-
import type { BootstrapEnvironmentProgress } from './payloads/bootstrap-environment-progress';
3-
import type { MissingContext, UpdatedContext } from './payloads/context';
4-
import type { BuildAsset, DeployConfirmationRequest, PublishAsset, StackDeployProgress, SuccessfulDeployStackResult } from './payloads/deploy';
5-
import type { StackDestroy, StackDestroyProgress } from './payloads/destroy';
6-
import type { StackDetailsPayload } from './payloads/list';
7-
import type { StackRollbackProgress } from './payloads/rollback';
8-
import type { SdkTrace } from './payloads/sdk-trace';
9-
import type { StackActivity, StackMonitoringControlEvent } from './payloads/stack-activity';
10-
import type { StackSelectionDetails } from './payloads/synth';
11-
import type { AssemblyData, ConfirmationRequest, Duration, ErrorPayload, StackAndAssemblyData } from './payloads/types';
12-
import type { FileWatchEvent, WatchSettings } from './payloads/watch';
13-
import type { MarkerDefinition } from './private/marker';
14-
import * as make from './private/message-maker';
2+
import type { MarkerDefinition } from './marker';
3+
import * as make from './message-maker';
4+
import type { BootstrapEnvironmentProgress } from '../payloads/bootstrap-environment-progress';
5+
import type { MissingContext, UpdatedContext } from '../payloads/context';
6+
import type { BuildAsset, DeployConfirmationRequest, PublishAsset, StackDeployProgress, SuccessfulDeployStackResult } from '../payloads/deploy';
7+
import type { StackDestroy, StackDestroyProgress } from '../payloads/destroy';
8+
import type { StackDetailsPayload } from '../payloads/list';
9+
import type { StackRollbackProgress } from '../payloads/rollback';
10+
import type { SdkTrace } from '../payloads/sdk-trace';
11+
import type { StackActivity, StackMonitoringControlEvent } from '../payloads/stack-activity';
12+
import type { StackSelectionDetails } from '../payloads/synth';
13+
import type { AssemblyData, ConfirmationRequest, Duration, ErrorPayload, StackAndAssemblyData } from '../payloads/types';
14+
import type { FileWatchEvent, WatchSettings } from '../payloads/watch';
1515

1616
/**
1717
* We have a rough system by which we assign message codes:

packages/@aws-cdk/toolkit-lib/build-tools/bundle.mjs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ const copyFromCli = (from, to = undefined) => {
1515
const bundleDeclarations = async (entryPoints) => {
1616
const results = generateDtsBundle(entryPoints.map(filePath => ({
1717
filePath,
18+
libraries: {
19+
importedLibraries: [
20+
'@aws-cdk/cx-api',
21+
'@aws-cdk/cloud-assembly-schema',
22+
'@aws-sdk/client-cloudformation',
23+
'aws-cdk-lib',
24+
'cdk-assets',
25+
],
26+
},
1827
output: {
1928
noBanner: true,
2029
exportReferencedTypes: false,
@@ -30,10 +39,13 @@ const bundleDeclarations = async (entryPoints) => {
3039
return Promise.all(files);
3140
}
3241

42+
// for the shared public API we also need to bundle the types
43+
const declarations = bundleDeclarations(['lib/api/shared-public.ts']);
44+
3345

3446
// This is a build script, we are fine
3547
// eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism
36-
await Promise.all([
48+
const resources = Promise.all([
3749
copyFromCli(['build-info.json']),
3850
copyFromCli(['/db.json.gz']),
3951
copyFromCli(['lib', 'index_bg.wasm']),
@@ -44,7 +56,7 @@ await Promise.all([
4456
]);
4557

4658
// bundle entrypoints from the library packages
47-
await esbuild.build({
59+
const bundle = esbuild.build({
4860
outdir: 'lib',
4961
entryPoints: [
5062
'lib/api/aws-cdk.ts',
@@ -59,5 +71,9 @@ await esbuild.build({
5971
bundle: true,
6072
});
6173

62-
// for the shared public API we also need to bundle the types
63-
await bundleDeclarations(['lib/api/shared-public.ts']);
74+
// Do all the work in parallel
75+
await Promise.all([
76+
bundle,
77+
resources,
78+
declarations
79+
]);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export * from '../../shared-public';
1+
export { IO, MARKER } from '../../shared-private';
22
export * from './io-host-wrappers';
33
export * from './sdk-logger';
4+

packages/@aws-cdk/toolkit-lib/lib/api/io/private/sdk-logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { inspect } from 'util';
33
import type { Logger } from '@smithy/types';
44
import { replacerBufferWithInfo } from '../../../private/util';
55
import type { IoHelper } from '../../shared-private';
6-
import { IO } from '../../shared-public';
6+
import { IO } from '../../shared-private';
77

88
export function asSdkLogger(ioHost: IoHelper): Logger {
99
return new class implements Logger {

packages/@aws-cdk/toolkit-lib/scripts/gen-code-registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs';
22
import * as util from 'util';
3-
import { IO } from '../lib/api/shared-public';
3+
import { IO } from '../lib/api/shared-private';
44

55
function codesToMarkdownTable(codes: Record<string, {
66
code: string;

packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { inspect, format } from 'util';
22
import { Logger } from '@smithy/types';
3-
import { IO } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/messages';
4-
import { IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private';
3+
import { IoHelper, IO } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private';
54
import { replacerBufferWithInfo } from '../../util';
65

76
export class SdkToCliLogger implements Logger {

0 commit comments

Comments
 (0)