Skip to content

Add support for inlining constants #1981

Description

@marvinhagemeister

With the fantastic addition in #1977 we're very close to switching our build pipeline away from rollup + terser over to esbuild. The speed improvement of esbuild is crazy good! Our current setup takes 4.8s and esbuild only 0.1s 🎉

Being a little obsessed with output size in the Preact team, the generated code by terser remains a little smaller.

esbuild: 4810 B (gzipped)
current: 4677 B (gzipped)

Comparing the generated output of both tools it seems to be mainly caused by terser being able to inline constant variables.

Example input:

const a = 1 << 1;
console.log(a);

esbuild output:

const a=1<<1;console.log(a);

Terser output:

console.log(2);

Here is the full output comparison of the Preact source: https://gist.github.com/marvinhagemeister/41a1b779650d335550eac7f5a825031f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions