Skip to content

Spread operator is not transpiled down #333

@flunderpero

Description

@flunderpero

First off, great work you are doing with esbuild!

We still have to support Edge 18 and we are running into a problem with our ServiceWorker - we cannot register it. This is similar to this SO thread. We used webpack before and hat to lower the target to ES2017.

I tried everything, but esbuild does not replace (all) spread operators in our build. I tried ES2015, edge18 and almost everything in between. :-) The generated code still contains lots of spread operators.

This is my build-config:

    esbuild.buildSync({
        entryPoints: ["ervice_worker.ts"],
        format: "iife",
        tsconfig: "tsconfig.json",
        define: {
            window: "self",
            global: "self",
            // some more project-specific stuff ...
        },
        outdir: "dist",
        sourcemap: "external",
        minifyIdentifiers: false,
        minifySyntax: true,
        minifyWhitespace: true,
        bundle: true,
        external: ["http", "https", "crypto", "stream"],  // we use shared code with NodeJS and remove the imports later on
        target: "es2015",
    })

The resulting code contains array spreads ([...a]), function call spreads (function a(...args)) but afaics no object spreads ({...o}).
Please note: Edge 18 does indeed support array and function call spreads, but service workers on Edge 18 do not.

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