Skip to content

Commit aaf2d80

Browse files
filipesilvamgechev
authored andcommitted
fix(@angular-devkit/architect): temporary workaround for TS bug with UMDs
The TS bug is microsoft/TypeScript#36780. The workaround is needed because `ts_library` emits UMDs currently. This will change with bazelbuild/rules_typescript#492 and bazel-contrib/rules_nodejs#1687.
1 parent 18ade22 commit aaf2d80

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/angular_devkit/architect/node/node-modules-architect-host.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
143143
}
144144

145145
async loadBuilder(info: NodeModulesBuilderInfo): Promise<Builder> {
146-
const builder = (await import(info.import)).default;
146+
// f1 const is a temporary workaround for a TS bug with UMDs.
147+
// See microsoft/TypeScript#36780. Should be removed when
148+
// https://github.com/bazelbuild/rules_typescript/pull/492 goes in.
149+
const f1 = info.import;
150+
const builder = (await import(f1)).default;
147151
if (builder[BuilderSymbol]) {
148152
return builder;
149153
}

packages/angular_devkit/architect/testing/testing-architect-host.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export class TestingArchitectHost implements ArchitectHost {
3636
this._builderMap.set(builderName, { builderName, description, optionSchema });
3737
}
3838
async addBuilderFromPackage(packageName: string) {
39-
const packageJson = await import(packageName + '/package.json');
39+
// f1 const is a temporary workaround for a TS bug with UMDs.
40+
// See microsoft/TypeScript#36780. Should be removed when
41+
// https://github.com/bazelbuild/rules_typescript/pull/492 goes in.
42+
const f1 = packageName + '/package.json';
43+
const packageJson = await import(f1);
4044
if (!('builders' in packageJson)) {
4145
throw new Error('Invalid package.json, builders key not found.');
4246
}
@@ -56,8 +60,13 @@ export class TestingArchitectHost implements ArchitectHost {
5660
const b = builders[builderName];
5761
// TODO: remove this check as v1 is not supported anymore.
5862
if (!b.implementation) { continue; }
59-
const handler = (await import(builderJsonPath + '/../' + b.implementation)).default;
60-
const optionsSchema = await import(builderJsonPath + '/../' + b.schema);
63+
// f2 and f3 consts are a temporary workaround for a TS bug with UMDs.
64+
// See microsoft/TypeScript#36780. Should be removed when
65+
// https://github.com/bazelbuild/rules_typescript/pull/492 goes in.
66+
const f2 = builderJsonPath + '/../' + b.implementation;
67+
const handler = (await import(f2)).default;
68+
const f3 = builderJsonPath + '/../' + b.schema;
69+
const optionsSchema = await import(f3);
6170
this.addBuilder(`${packageJson.name}:${builderName}`, handler, b.description, optionsSchema);
6271
}
6372
}

0 commit comments

Comments
 (0)