Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular-output-target): multiple targets do not overwrite each other #376

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions packages/angular-output-target/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ import { angularDirectiveProxyOutput } from './output-angular';
import type { OutputTargetAngular } from './types';
import path from 'path';

let validatedOutputTarget: OutputTargetAngular;

export const angularOutputTarget = (outputTarget: OutputTargetAngular): OutputTargetCustom => ({
type: 'custom',
name: 'angular-library',
validate(config) {
validatedOutputTarget = normalizeOutputTarget(config, outputTarget);
},
async generator(config, compilerCtx, buildCtx) {
const timespan = buildCtx.createTimeSpan(`generate angular proxies started`, true);

await angularDirectiveProxyOutput(compilerCtx, validatedOutputTarget, buildCtx.components, config);

timespan.finish(`generate angular proxies finished`);
},
});
export const angularOutputTarget = (outputTarget: OutputTargetAngular): OutputTargetCustom => {
let validatedOutputTarget: OutputTargetAngular;

return {
type: 'custom',
name: 'angular-library',
validate(config) {
validatedOutputTarget = normalizeOutputTarget(config, outputTarget);
},
async generator(config, compilerCtx, buildCtx) {
const timespan = buildCtx.createTimeSpan(`generate angular proxies started`, true);

await angularDirectiveProxyOutput(compilerCtx, validatedOutputTarget, buildCtx.components, config);

timespan.finish(`generate angular proxies finished`);
},
};
};

export function normalizeOutputTarget(config: Config, outputTarget: OutputTargetAngular) {
const results: OutputTargetAngular = {
Expand Down