Skip to content

Commit 733efe7

Browse files
filipesilvavikerman
authored andcommitted
fix(@angular-devkit/build-optimizer): prefix renamed extended classes (#13613)
Fix #11796
1 parent 4ecd232 commit 733efe7

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

packages/angular_devkit/build_optimizer/src/transforms/prefix-classes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function testPrefixClasses(content: string) {
3030
exportVarSetter, multiLineComment,
3131
/\(/, multiLineComment,
3232
/\s*function \(_super\) {/, newLine,
33-
/\w*\.?__extends\(\w+, _super\);/,
33+
/\S*\.?__extends\(\S+, _super\);/,
3434
],
3535
].map(arr => new RegExp(arr.map(x => x.source).join(''), 'm'));
3636

packages/angular_devkit/build_optimizer/src/transforms/prefix-classes_spec.ts

+34
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,40 @@ describe('prefix-classes', () => {
193193
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
194194
});
195195

196+
it('prefix TS 2.5 - 2.6 renamed downlevel class with extends', () => {
197+
const input = tags.stripIndent`
198+
var NgModuleFactory$1 = /** @class */ (function (_super) {
199+
__extends(NgModuleFactory$$1, _super);
200+
function NgModuleFactory$$1(moduleType) {
201+
var _this = _super.call(this) || this;
202+
_this.moduleType = moduleType;
203+
return _this;
204+
}
205+
NgModuleFactory$$1.prototype.create = function (parentInjector) {
206+
return new NgModuleRef$1(this.moduleType, parentInjector);
207+
};
208+
return NgModuleFactory$$1;
209+
}(NgModuleFactory));
210+
`;
211+
const output = tags.stripIndent`
212+
var NgModuleFactory$1 = /** @class */ /*@__PURE__*/ (function (_super) {
213+
__extends(NgModuleFactory$$1, _super);
214+
function NgModuleFactory$$1(moduleType) {
215+
var _this = _super.call(this) || this;
216+
_this.moduleType = moduleType;
217+
return _this;
218+
}
219+
NgModuleFactory$$1.prototype.create = function (parentInjector) {
220+
return new NgModuleRef$1(this.moduleType, parentInjector);
221+
};
222+
return NgModuleFactory$$1;
223+
}(NgModuleFactory));
224+
`;
225+
226+
expect(testPrefixClasses(input)).toBeTruthy();
227+
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
228+
});
229+
196230
it('prefix TS 2.5 - 2.6 downlevel class with static variable', () => {
197231
const input = tags.stripIndent`
198232
var StaticTestCase = /** @class */ (function () {

0 commit comments

Comments
 (0)