Skip to content

Object shape tree-shaking #2201

@guybedford

Description

@guybedford

Supporting tree-shaking of:

var p = {
  a: 'a',
  b: 'b'
};
externalFn(p.a);

into:;

var p = {
  a: 'a'
};
externalFn(p.a);

So basically, knowing that the object itself is not exposed and then being able to remove properties known not to be used at all.

Ideally to extend this into cases like:

var p = {};
p.a = 'a';
p.b = 'b';
externalFn(p.a);

as well, also supporting the same sort of thing.

The same principles can likely apply to class shape too, although there's much more exposure for classes potentially to track, likely with a more costly analysis and higher opt-out rate so worth weighing that up separately perhaps.

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