Skip to content

fix(@angular-devkit/build-optimizer): wrap classes with a let variable #14989

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

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ function createWrappedClass(
ts.createVariableDeclarationList([
ts.createVariableDeclaration(name, undefined, pureIife),
],
ts.NodeFlags.Const,
ts.NodeFlags.Let,
),
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const CustomComponentEffects = /*@__PURE__*/ (() => {
let CustomComponentEffects = /*@__PURE__*/ (() => {
${defaultClass.replace('export default ', '')}

return CustomComponentEffects;
})();
export default CustomComponentEffects;

const CustomComponent = /*@__PURE__*/ (() => {
let CustomComponent = /*@__PURE__*/ (() => {
${namedClass}

return CustomComponent;
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const CustomComponentEffects = /*@__PURE__*/ (() => {
let CustomComponentEffects = /*@__PURE__*/ (() => {
${input}

return CustomComponentEffects;
Expand All @@ -104,7 +104,7 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const ApplicationModule = /*@__PURE__*/ (() => {
let ApplicationModule = /*@__PURE__*/ (() => {
${input}

return ApplicationModule;
Expand All @@ -131,7 +131,7 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const CommonModule = /*@__PURE__*/ (() => {
let CommonModule = /*@__PURE__*/ (() => {
${input}

return CommonModule;
Expand All @@ -154,7 +154,7 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
export const Foo = /*@__PURE__*/ (() => {
export let Foo = /*@__PURE__*/ (() => {
${input.replace('export ', '')}

return Foo;
Expand All @@ -170,7 +170,7 @@ describe('wrap enums and classes transformer', () => {
TemplateRef.__NG_ELEMENT_ID__ = () => SWITCH_TEMPLATE_REF_FACTORY(TemplateRef, ElementRef);
`;
const output = tags.stripIndent`
export const TemplateRef = /*@__PURE__*/ (() => {
export let TemplateRef = /*@__PURE__*/ (() => {
class TemplateRef { }
TemplateRef.__NG_ELEMENT_ID__ = () => SWITCH_TEMPLATE_REF_FACTORY(TemplateRef, ElementRef);
return TemplateRef;
Expand All @@ -187,7 +187,7 @@ describe('wrap enums and classes transformer', () => {
TemplateRef.somethingElse = true;
`;
const output = tags.stripIndent`
export const TemplateRef = /*@__PURE__*/ (() => {
export let TemplateRef = /*@__PURE__*/ (() => {
class TemplateRef {
}
TemplateRef.__NG_ELEMENT_ID__ = () => SWITCH_TEMPLATE_REF_FACTORY(TemplateRef, ElementRef);
Expand Down Expand Up @@ -231,14 +231,14 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const Foo = /*@__PURE__*/ (() => {
let Foo = /*@__PURE__*/ (() => {
${defaultClass.replace('export default Foo;', '')}

return Foo;
})();
export default Foo;

const AggregateColumnDirective = /*@__PURE__*/ (() => {
let AggregateColumnDirective = /*@__PURE__*/ (() => {
${namedClass}

return AggregateColumnDirective;
Expand All @@ -261,7 +261,7 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const AggregateColumnDirective = /*@__PURE__*/ (() => {
let AggregateColumnDirective = /*@__PURE__*/ (() => {
${input}

return AggregateColumnDirective;
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('wrap enums and classes transformer', () => {

const output = tags.stripIndent`
var FooDirective_1;
const FooDirective = /*@__PURE__*/ (() => {
let FooDirective = /*@__PURE__*/ (() => {
${classContent}

return FooDirective;
Expand All @@ -316,7 +316,7 @@ describe('wrap enums and classes transformer', () => {
`;

const output = tags.stripIndent`
const ChipList = /*@__PURE__*/ (() => {
let ChipList = /*@__PURE__*/ (() => {
${input}
return ChipList;
})();`;
Expand Down Expand Up @@ -349,7 +349,7 @@ describe('wrap enums and classes transformer', () => {
ChipList = __decorate$4([NotifyPropertyChanges], ChipList);`;

const output = tags.stripIndent`
const ChipList = /*@__PURE__*/ (() => {
let ChipList = /*@__PURE__*/ (() => {
${input}
return ChipList;
})();`;
Expand Down Expand Up @@ -394,7 +394,7 @@ describe('wrap enums and classes transformer', () => {
const output = tags.stripIndent`
const minutesMilliSeconds = 60000;

const AggregateColumnDirective = /*@__PURE__*/ (() => {
let AggregateColumnDirective = /*@__PURE__*/ (() => {
${firstClass}

return AggregateColumnDirective;
Expand All @@ -403,7 +403,7 @@ describe('wrap enums and classes transformer', () => {
const CSS = 'e-css';
const PRIMARY = 'e-primary';

const ChipList = /*@__PURE__*/ (() => {
let ChipList = /*@__PURE__*/ (() => {
${secondClass}

return ChipList;
Expand Down