Skip to content

Incomplete tree shaking (cjs?) #898

@Benjamin-Dobell

Description

@Benjamin-Dobell

Version

"rollup version 0.34.13"

Details

I have an ES6 module ("dom") that looks like this:


// ... code ...

var isDescendant = function(parent, child) {
    // ... code ...
};

// ... code ...

export {
    addEventListener,
    getElementContentWidth,
    getElementContentHeight,
    removeAllChildren,
    isDescendant,
    loadCss
};

The tree shaking is detecting that isDescendant is not called, and hence:

var isDescendant = function(parent, child) {
    // ... code ...
};

is completely removed from my target CJS bundle.

However, the "transpiled" export referring to isDescendent is left in place:

var dom = Object.freeze({
    addEventListener: addEventListener,
    getElementContentWidth: getElementContentWidth,
    getElementContentHeight: getElementContentHeight,
    removeAllChildren: removeAllChildren,
    isDescendant: isDescendant,
    loadCss: loadCss
});

Which results in "ReferenceError: isDescendant is not defined".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions