Skip to content

add config option to control async/await transpilation #30656

@dartzki

Description

@dartzki

Command

build, run, e2e, serve, test

Description

angular-cli introduced a heuristic to decide whether to transpile aync/await or use the native application.
since transpilation is necessary for zone.js, the heuristic executed transpilation if zone.js is added as polyfil or if any file with a file extension is added.

source: https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/tools/esbuild/utils.ts#L477

Our angular app runs alongside other scripts which are not under our control. Therefore we separated zone.js from the angular bundle and instead import it manually as first script of the page (loading the angular bundle as first script is not an option).
Therefore we do not include zone.js in the polyfills array in angular.json.

Without the zone.js polyfills, the angular-cli does not transpile async/await which then results in broken change-detection as zone.js does not support native async/await.

Describe the solution you'd like

A config option to force async/await transpilation independent of the content of the polyfills array.

This would give a solution for the problem of unwanted transpilation in zoneless applications (#29853)

Describe alternatives you've considered

As a workaround we are adding an empty javascript file to the polyfills array.

We considered changing our base page/integration setup such that the angular bundle is loaded first, but the impact on the overall architecture of the company-wide solution is too big.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions