Skip to content

Commit

Permalink
fix(treeshaking): update build conditional treeskaking optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jun 30, 2020
1 parent 36b4978 commit 2ba24b1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/runtime/update-component.ts
Expand Up @@ -146,15 +146,23 @@ const updateComponent = (hostRef: d.HostRef, instance: any, isInitialLoad: boole
let renderingRef: any = null;

const callRender = (hostRef: d.HostRef, instance: any) => {
// in order for bundlers to correctly treeshake the BUILD object
// we need to ensure BUILD is not deoptimized within a try/catch
// https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
const allRenderFn = BUILD.allRenderFn ? true : false;
const lazyLoad = BUILD.lazyLoad ? true : false;
const taskQueue = BUILD.taskQueue ? true : false;
const updatable = BUILD.updatable ? true : false;

try {
renderingRef = instance;
instance = BUILD.allRenderFn ? instance.render() : instance.render && instance.render();
instance = allRenderFn ? instance.render() : instance.render && instance.render();

if (BUILD.updatable && BUILD.taskQueue) {
if (updatable && taskQueue) {
hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
}

if (BUILD.updatable || BUILD.lazyLoad) {
if (updatable || lazyLoad) {
hostRef.$flags$ |= HOST_FLAGS.hasRendered;
}
} catch (e) {
Expand Down

0 comments on commit 2ba24b1

Please sign in to comment.