-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow for tree-shaking unused langauges translations in custom apps #19799
base: epic/tew-translation
Are you sure you want to change the base?
Conversation
…- to relative public_api.ts
…ame (chunk name) is in kebab-case, then convert the chunk name to camelCase (without changing the original JSON file)
…nch with latest translations
…ix>TranslationsEn` instead of the deprecated `<prefix>Translations` wrapper object
…slations-ts-barrels.config'
I encountered two issues when tried to build libs for QA purposes:
|
import { ja } from './ja/index'; | ||
import { de } from './de/index'; | ||
import { zh } from './zh/index'; | ||
import { extractTranslationChunksConfig } from '@spartacus/core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
major:
this line causes the build error described here: #19799 (comment)
After tweaking mentioned issues locally I went through the QA steps and everything works as expected 🔥 |
index.ts
files to re-export JSON translations in TS for new langaugestranslations.ts
barrel files, to export each langauge in a separate public API members (to allow for treeshaking unused langauges). Note: it preservers the old feature prefix (e.g.asmTranslations
->asmTranslationsEn
,asmTranslationsDe
, ...)asmTranslations
(and moved those deprecated tokens topublic_api.ts
files fromtranslations.ts
files)asmTranslations
langauges other thanen
(in other words: revert the change made previously on the branch epic/tew-translation which added 3 other langauges into those wrapper objects)extractTranslationChunksConfig()
in@spartacus/core
and use it in every library for creating chunks config in theirtranslation.ts
files. It extracts the chunks config from the translations assets automatically. So no more need to type chunks config manually.By the way:
extractTranslationChunksConfig()
myAccountV2NotifiationPerference
, HOWEVER I didn't fix it in this PR - it should be done in a separate PRmy-account-v2-notification-perference.json
(btw. it's a different typo than the above chunk name), HOWEVER I didnt fix it in this PRThe reason I didn't want to fix those things by the way is:
TODO
related to https://jira.tools.sap/browse/CXSPA-9131
QA steps
npx @angular/cli@17 new test-app --standalone=false --ssr=false
ng add @spartacus/schematics@2211.32. 0-1 --baseUrl="https://40.76.109. 9:9002" --ssr
AND PLEASE SELECT ALL possible features and integrations in the interactive promptresources:
and verify that everywhere in every feature module we use the new approach with explicit EN translationstranslations
wrapper object and verify it's@deprecated
(crossed out in VSCode)http-server
)ng build
(or for interactive mode runnpm run watch
). Don't tryng serve --configuration=production
- it doesn't have so well tree shaking asng build
npx http-server dist/test-app/browser
(or for interactive mode run in another terminalnpx nodemon --watch "./dist/test-app/browser" --exec "npx http-server './dist/$test-app/browser'" --ext "*"
ariaLabelSuggestions
and verify that in the loadedmain.js
file there are only 2 langauges (EN and DE which you have enabled in steps above) with translations for this key