angular/packages/localize/init
Paul Gschwendtner 4c56c45075 refactor(localize): init APF entry-point should not duplicate code (#45405)
This commit addresses two issues:

* The init entry-point currenly access code from another entry-point
  using relative imports, resulting in code to be duplicated.
* The init types are now bundled as part of the ng_package APF rule.
  There is an API extractor bundling issue with global module
  augmentations.

API extractor does not properly handle module augmentation. We need to disable
dts bundling for this entry-point to ensure `$localize` remains globally accessible
for users. This is an option in the `ng_package` rule.

Note that this worked before because `localize/init` was a `ts_library` that did not
have its types bundled.

As part of this change, the `MessageId` and `TargetMessage` exports are
also made public. The localize exported functions rely on these types but
they were not exported.

Related to types, an exception is added for three private exports from the primary
entry-point so that they will show up in the API golden. These private
exports are re-exposed publicly in the init entry-point but no golden
would capture them due to the private symbol prefix. One might wonder
why the symbols are not guarded in the init golden. The reason is that
goldens never inline signatures from cross-entry-points/packages to avoid
duplication.

Lastly, the i18n integration test golden had to be updated because the
polyfills bundle increased slightly. After thorough and time-consuming
investigation, this mostly happens due to different mangle identifies
being used (the input code changed --> so the mangling determinism)

Size before this change:

```
SUCCESS: Commit undefined uncompressed runtime did NOT cross size threshold of 500 bytes or >1% (expected: 929, actual: 926).
SUCCESS: Commit undefined uncompressed main did NOT cross size threshold of 500 bytes or >1% (expected: 124544, actual: 124660).
SUCCESS: Commit undefined uncompressed polyfills did NOT cross size threshold of 500 bytes or >1% (expected: 34530, actual: 34641).
```

After:

```
SUCCESS: Commit undefined uncompressed runtime did NOT cross size threshold of 500 bytes or >1% (expected: 929, actual: 926).
SUCCESS: Commit undefined uncompressed main did NOT cross size threshold of 500 bytes or >1% (expected: 124544, actual: 124650).
FAIL: Commit undefined uncompressed polyfills exceeded expected size by 500 bytes or >1% (expected: 34530, actual: 35252).
```

Inspecting/comparing without mangling shows that the new changes would
actually result in a bundle reduction (potentially visible with
gzip/brotli):

```
➜  Desktop stat -f%z  master-nomangle.js
101357
➜  Desktop stat -f%z  with-changes-nomangle.js
101226
```

PR Close #45405
2022-04-21 11:09:39 -07:00
..
BUILD.bazel refactor(localize): init APF entry-point should not duplicate code (#45405) 2022-04-21 11:09:39 -07:00
index.ts refactor(localize): init APF entry-point should not duplicate code (#45405) 2022-04-21 11:09:39 -07:00
PACKAGE.md docs(localize): expose documentation for the @angular/localize package (#40317) 2021-03-19 12:36:10 -07:00