Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Add a tree shaking test that involves the use of Flow types #771

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add a tree shaking test that involves the use of Flow types #771

wants to merge 1 commit into from

Conversation

AlexMSmithCA
Copy link
Member

@AlexMSmithCA AlexMSmithCA commented May 6, 2019

As part of the investigation into looking into WPT-2994 this PR adds a new test to ensure that imports/exports that include Flow types are properly stripped and tree shaken.

@AlexMSmithCA AlexMSmithCA self-assigned this May 6, 2019

// used in the browser
// - node modules
const usedDepVal: UsedDependencyType = { shouldBeUsed: usedDependencyValue};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 51-52 here cause the vendor bundle to leak the unused import from fixture-pckg (__FIXTURE_DEPENDENCY_UNUSED__ which should be used only in the server bundle):

/*! no static exports found */function(e,o,s){"use strict";Object.defineProperty(o,"__esModule",{value:!0});o.usedDependencyValue="__FIXTURE_DEPENDENCY_USED__",o.unusedDependencyValue="__FIXTURE_DEPENDENCY_UNUSED__"}}]);

Removing these two lines tree shakes the import for fixture-pckg.

@@ -0,0 +1,11 @@
'use strict';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We couldn't have export type declarations in the dependency's entry point, so maybe this test isn't the best...

Currently using the transpiled index.js here and added an index.js.flow file for Flow/IDE integration.

@AlexMSmithCA
Copy link
Member Author

I was having trouble reproducing whether code was leaking into the browser due to Flow imports:

e.g.

import type {AType} from ... // no leak
import {B} from ...

vs.

import {type AType, B} from ... // potential leak

Not entirely sure why, but tree splitting seems to be failing for node module dependency imports as a separate concern.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant