Skip to content

Commit

Permalink
fix: app build error with new builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Jan 22, 2024
1 parent aa65acb commit 4a5f9bd
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions angular/app-types/angular-app-type/application.bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
loadEsmModule,
normalizePath
} from '@bitdev/angular.dev-services.common';
import { buildApplicationInternal } from '@bitdev/angular.dev-services.ng-compat';
import {
type ApplicationBuilderOptions,
buildApplicationInternal, type DevServerBuilderOptions
} from '@bitdev/angular.dev-services.ng-compat';
import { Logger } from '@teambit/logger';
import assert from 'assert';
import { outputFileSync } from 'fs-extra';
Expand All @@ -27,6 +30,10 @@ export type BuildApplicationOptions = {
entryServer?: string;
}

// TODO allow customizing this
const BUILDER_NAME = '@angular-devkit/build-angular:application';
const CACHE_PATH = 'angular/cache';

export async function buildApplication(options: BuildApplicationOptions): Promise<void> {
const { angularOptions: { tsConfig, ssr } } = options;
const isSsr = !!ssr && Number(VERSION.major) >= 17;
Expand All @@ -38,7 +45,7 @@ export async function buildApplication(options: BuildApplicationOptions): Promis
}

const appOptions = getAppOptions(options, isSsr);
const builderContext = getBuilderContext(options);
const builderContext = getBuilderContext(options, appOptions);
const builderPlugins: any[] = [];

for await (const result of buildApplicationInternal(
Expand Down Expand Up @@ -126,12 +133,12 @@ function getAppOptions(options: BuildApplicationOptions, isSsr: boolean): any {
}


function getBuilderContext(options: BuildApplicationOptions): any {
function getBuilderContext(options: BuildApplicationOptions, appOptions: ApplicationBuilderOptions): any {
const { workspaceRoot, sourceRoot, tempFolder } = options;
return {
id: 1,
builder: {
builderName: '@bitdev/build-angular:application',
builderName: BUILDER_NAME,
description: 'Bit Angular Application Builder',
optionSchema: {}
},
Expand All @@ -149,7 +156,14 @@ function getBuilderContext(options: BuildApplicationOptions): any {
sourceRoot,
cli: { cache: { enabled: true, path: resolve(tempFolder, 'angular/cache') } }
});
}
},
addTeardown: (teardown: () => Promise<void> | void) => {
teardown();
return;
},
getBuilderNameForTarget: () => Promise.resolve(BUILDER_NAME),
getTargetOptions: () => Promise.resolve(appOptions as any),
validateOptions: () => Promise.resolve(appOptions as any)
};
}

Expand Down

0 comments on commit 4a5f9bd

Please sign in to comment.