mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
fix(@angular-devkit/build-optimizer): don't wrap classes which static properties have been removed
At the moment the `wrap-enums` transfomers is being run prior to `scrub-file` and this is resulting classes which all static properties have been dropped to be wrapped in IIFE.
This commit is contained in:
parent
e1c616b0f6
commit
20b16a247a
@ -149,7 +149,7 @@ export function buildOptimizer(options: BuildOptimizerOptions): TransformJavascr
|
|||||||
getTransforms.unshift(getImportTslibTransformer);
|
getTransforms.unshift(getImportTslibTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTransforms.unshift(getWrapEnumsTransformer);
|
getTransforms.push(getWrapEnumsTransformer);
|
||||||
|
|
||||||
const transformJavascriptOpts: TransformJavascriptOptions = {
|
const transformJavascriptOpts: TransformJavascriptOptions = {
|
||||||
content: content,
|
content: content,
|
||||||
|
@ -99,6 +99,35 @@ describe('build-optimizer', () => {
|
|||||||
expect(tags.oneLine`${boOutput.content}`).toEqual(output);
|
expect(tags.oneLine`${boOutput.content}`).toEqual(output);
|
||||||
expect(boOutput.emitSkipped).toEqual(false);
|
expect(boOutput.emitSkipped).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not wrap classes which had all static properties dropped in IIFE', () => {
|
||||||
|
const classDeclaration = tags.oneLine`
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
class Platform {
|
||||||
|
constructor(_doc) {
|
||||||
|
}
|
||||||
|
init() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const input = tags.oneLine`
|
||||||
|
${classDeclaration}
|
||||||
|
|
||||||
|
Platform.decorators = [
|
||||||
|
{ type: Injectable }
|
||||||
|
];
|
||||||
|
|
||||||
|
/** @nocollapse */
|
||||||
|
Platform.ctorParameters = () => [
|
||||||
|
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT] }] }
|
||||||
|
];
|
||||||
|
`;
|
||||||
|
|
||||||
|
const boOutput = buildOptimizer({ content: input, isSideEffectFree: true });
|
||||||
|
expect(tags.oneLine`${boOutput.content}`).toEqual(classDeclaration);
|
||||||
|
expect(boOutput.emitSkipped).toEqual(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user