Skip to content

Treeshaking is defeated by parenthesis.  #1128

Description

@mhevery

main.js

import {VERSION} from './core.js';

core.js

function makeVersion(full) {
    return Object.create(Version.prototype, {
        full: { value: full }
    });
}
var Version = makeVersion;

export var VERSION = new Version('0.0.0');

Results in an empty file. which is correct. Now change single line like so:

var Version = (makeVersion); // add parenthesis

And now the result is:

'use strict';

function makeVersion(full) {
    return Object.create(Version.prototype, {
        full: { value: full }
    });
}
var Version = (makeVersion);


var VERSION = new Version('0.0.0');

I would expect that adding of parenthesis should not change the result of tree shaking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions