Skip to content

impr: Flatten externals #2414

@aleksanderkatan

Description

@aleksanderkatan

TO BE RECONSIDERED: we now generate error messages based on AST, this would obfuscate them.

Blocked by #2019

Externals can be flattened to save memory. For example:

const foo = () => {
  'use gpu';
  const a = this.config.multiplier;
  const b = this.config.zero;
  const c = this.config.multiplier;
};

const externals = {
  'this': {
    'config': {
      'multiplier': () => this.config.multiplier,
      'zero': () => this.config.zero,
    },
  }
}

can later on be simplified to

const foo = () => {
  'use gpu';
  const a = d; // only in AST, the function code is left as is
  const b = e;
  const c = d;
};

const externals = {
  'd': () => this.config.multiplier,
  'e': () => this.config.zero,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions