Skip to content

Commit

Permalink
refactor: workaround tree shakable expression
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomiassaf committed Jun 12, 2019
1 parent e2d9960 commit c602bd9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 5 additions & 1 deletion libs/ngrid/drag/src/lib/column-resize/extend-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ declare module '@pebula/ngrid/lib/table/columns/types' {
}
}

PblColumn.extendProperty('resize');
// We trick the tree-shaker with an IIFE so it will not remove the function call expression
PblColumn.prototype.updateWidth = (function() {
PblColumn.extendProperty('resize');
return PblColumn.prototype.updateWidth;
})();
15 changes: 9 additions & 6 deletions libs/ngrid/drag/src/lib/drag-and-drop/column/extend-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ function checkGroupLockConstraint(this: PblColumn, column: PblColumn): boolean {
return true;
}

PblColumn.extendProperty('reorder');
PblColumn.extendProperty('wontBudge');
PblColumn.prototype.checkGroupLockConstraint = function (this: PblColumn, column: PblColumn): boolean {
return checkGroupLockConstraint.call(this, column) && checkGroupLockConstraint.call(column, this);
}
// We trick the tree-shaker with an IIFE so it will not remove the function call expression
PblColumn.prototype.checkGroupLockConstraint = (function() {
PblColumn.extendProperty('reorder');
PblColumn.extendProperty('wontBudge');
PblColumnGroup.extendProperty('lockColumns');

PblColumnGroup.extendProperty('lockColumns');
return function (this: PblColumn, column: PblColumn): boolean {
return checkGroupLockConstraint.call(this, column) && checkGroupLockConstraint.call(column, this);
};
})();
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { UnRx } from '@pebula/utils';
import { PblColumn, PblNgridComponent, PblNgridPluginController } from '@pebula/ngrid';
import { PblNgridTargetEventsPlugin } from './target-events-plugin';

PblColumn.extendProperty('editable');
// We trick the tree-shaker with an IIFE so it will not remove the function call expression
PblColumn.prototype.updateWidth = (function() {
PblColumn.extendProperty('editable');
return PblColumn.prototype.updateWidth;
})();


@Directive({
// tslint:disable-next-line:directive-selector
Expand Down

0 comments on commit c602bd9

Please sign in to comment.