Skip to content

ngcc: processing of recently published UMD bundles may fail #44037

@JoostK

Description

@JoostK

Problem description

Recently, a number of issues (#43870, #43936, #44019) has started to occur for certain UMD bundles when ngcc (the Angular Compatibility Compiler) processes them to create an Ivy-compatible version of the UMD bundle.

Recent changes to how UMD bundles are formatted are not supported by the current Angular Compatibility Compiler (ngcc), which can result in a fatal error, like the following:

  • TypeError: Cannot read property 'text' of undefined
  • Error: Failed to find exported name of node

Packages from the @angular scope are not affected, but recent versions of third-party libraries may result in one of the above fatal errors.

In the typical Angular CLI setup UMD bundles are not generally needed, as ES2015 bundles are preferred over UMD. It is therefore expected that CLI users won't be affected by these issues.

Available workarounds

If ngcc is manually executed from outside of the CLI, without the --properties argument, then it will process all available formats in a library including the UMD bundles. In that case, ngcc may fail if a library is used that contains the newly structured code that ngcc is currently unable to understand. It may be that the UMD bundles are not actually necessary, in which case ngcc can be configured not to process the UMD bundles at all. To this effect, pass the --properties es2015 module argument to ngcc.

If you do require the UMD bundles to be processed, for example if you're using Jest for unit testing, then the only workaround that is currently available is to pin the dependency that breaks ngcc to an earlier version which does not contain the problematic code patterns that cause ngcc to fail.

Next steps

Although some of the changes have already been accounted for in the latest Angular 12 releases, we're still working on a solution to resolve all ngcc failures of UMD bundles.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions