Reproduction repository to showcase problems with tree-shaking of i18n extractions.
This repository contains:
- a library at
/projects/my-library
. This library contains and exports a single module/component. - a library at
/projects/library-with-localize
. This library contains and exports a single module/component. - an application at
/src/...
. It imports the library modules in theapp.module.ts
but does not use the exported library components anywhere.
Unused translation strings are included in the apps extracted translations. It seems like only translations are included from files that don't explicitly import and use the $localize
function.
# install dependencies
yarn install
# build the libraries
yarn ng build my-library && yarn ng build library-with-localize
# extract translations
yarn ng extract-i18n
Now confirm that the generated messages.xlf
file contains unused translations from only these components that don't explicitly import and use $localize
.