In some cases, where a module imports a dependency but does not actually use it, UMD bundlers may remove the dependency parameter from the UMD factory function definition. For example: ``` import * as x from 'x'; import * as z from 'z'; export const y = x; ``` may result in a UMD bundle including: ``` (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x'), require('z')) : typeof define === 'function' && define.amd ? define(['exports', 'x', 'z'], factory) : (global = global || self, factory(global.myBundle = {}, global.x)); }(this, (function (exports, x) { 'use strict'; ... }))); ``` Note that while the `z` dependency is provide in the call, the factory itself only accepts `exports` and `x` as parameters. Previously ngcc appended new dependencies to the end of the factory function, but this breaks in the above scenario. Now the new dependencies are prefixed at the front of parameters/arguments already in place. Fixes #34653 PR Close #34660
Angular Compatibility Compiler (ngcc)
This compiler will convert node_modules
compiled with ngc
, into node_modules
which
appear to have been compiled with ngtsc
.
This conversion will allow such "legacy" packages to be used by the Ivy rendering engine.
Building
The project is built using Bazel:
yarn bazel build //packages/compiler-cli/ngcc
Unit Testing
The unit tests are built and run using Bazel:
yarn bazel test //packages/compiler-cli/ngcc/test
Integration Testing
There are tests that check the behavior of the overall executable:
yarn bazel test //packages/compiler-cli/ngcc/test:integration