fix(@angular-devkit/architect): temporary workaround for TS bug with UMDs

The TS bug is https://github.com/microsoft/TypeScript/issues/36780.

The workaround is needed because `ts_library` emits UMDs currently. This will change with https://github.com/bazelbuild/rules_typescript/pull/492 and https://github.com/bazelbuild/rules_nodejs/pull/1687.
This commit is contained in:
Filipe Silva 2020-03-05 15:24:09 +00:00 committed by Minko Gechev
parent 18ade225ba
commit aaf2d802a8
2 changed files with 17 additions and 4 deletions

View File

@ -143,7 +143,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
}
async loadBuilder(info: NodeModulesBuilderInfo): Promise<Builder> {
const builder = (await import(info.import)).default;
// f1 const is a temporary workaround for a TS bug with UMDs.
// See microsoft/TypeScript#36780. Should be removed when
// https://github.com/bazelbuild/rules_typescript/pull/492 goes in.
const f1 = info.import;
const builder = (await import(f1)).default;
if (builder[BuilderSymbol]) {
return builder;
}

View File

@ -36,7 +36,11 @@ export class TestingArchitectHost implements ArchitectHost {
this._builderMap.set(builderName, { builderName, description, optionSchema });
}
async addBuilderFromPackage(packageName: string) {
const packageJson = await import(packageName + '/package.json');
// f1 const is a temporary workaround for a TS bug with UMDs.
// See microsoft/TypeScript#36780. Should be removed when
// https://github.com/bazelbuild/rules_typescript/pull/492 goes in.
const f1 = packageName + '/package.json';
const packageJson = await import(f1);
if (!('builders' in packageJson)) {
throw new Error('Invalid package.json, builders key not found.');
}
@ -56,8 +60,13 @@ export class TestingArchitectHost implements ArchitectHost {
const b = builders[builderName];
// TODO: remove this check as v1 is not supported anymore.
if (!b.implementation) { continue; }
const handler = (await import(builderJsonPath + '/../' + b.implementation)).default;
const optionsSchema = await import(builderJsonPath + '/../' + b.schema);
// f2 and f3 consts are a temporary workaround for a TS bug with UMDs.
// See microsoft/TypeScript#36780. Should be removed when
// https://github.com/bazelbuild/rules_typescript/pull/492 goes in.
const f2 = builderJsonPath + '/../' + b.implementation;
const handler = (await import(f2)).default;
const f3 = builderJsonPath + '/../' + b.schema;
const optionsSchema = await import(f3);
this.addBuilder(`${packageJson.name}:${builderName}`, handler, b.description, optionsSchema);
}
}