-
Notifications
You must be signed in to change notification settings - Fork 30
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
AOT bundle files #29
Comments
Hello, I'm not planning on adding new features or optimizations to this library, because like you said it's only a temporary solution. |
Our project has around 300 translated strings for english and french the raw xlf files are around 250K. After investigating the bundled code further it appears that it is saving the english and french file in the bundle even though we are building the bundle once for english and once for french as described in the documentation. One way to reduce the size is during the load operation it could remove the |
I've been looking into this some more and have made a few observations, I wonder if you could comment on if we are doing something wrong with our setup. In our current setup we make no reference to Now trying to use the So to summerize it appears that:
|
Yes that's correct. The reason is that this is an external library, not part of the framework itself. When Angular is built, it will replace texts in the templates, but not in the service (since it's just another external lib for the compiler). When runtime i18n lands in the framework for Angular v7, then the built-in service will use the same translations for code and templates. |
Thank you for all the information, I had one last confirmation question. So when v7 releases will it be possible to do |
Came here to ask the same thing. Actually it's much worse for us. The XLIFF 1.2 is 340kb and our bundle grew from 1.8mb to 3.6mb (doubled). Thought there was something wrong when I saw the XLIFF actually embedded into my bundle but see that it's expected :( Created 2x bundles (english and french) and I can see both messages(en).xlf and messages(fr).xlf are both embedded in both bundles. Our build command looks like: ./node_modules/.bin/ng "build" "--app=mysite" "--environment=prod" "--i18n-file=src/mysite/locale/messages(en).xlf" "--locale=en" "--missing-translation=ignore" "--output-path=dist/mysite/en" "--prod" "--base-href=/en/" "--deploy-url=/en/" Bundle looks like:
Was expecting a JSON map like: {
"5e6548eb9cbb0467c307b4079bc989cd21f44355": "This field is required"
} Later down the line I see this in my bundle as well. Maybe these could be directly replaced with i18n being a NOOP?
So I guess a couple of things:
Maybe after all of the post-processing, 94kb extra within the bundle would be an acceptable trade-off for all the savings generated from reducing HTML |
@intellix about a script to remove |
in jetbrain ide's it's quite simple to replace all context-groups with a regex search => "[\s\S]*?</context-group>" |
This is the regex for the vscode, in case someone is interested in reducing the bundle size: |
@cngarkar Basically the same as i already commented. But also to mention, with angular 9 use the newly written i18n tools and it's no longer necessary to use the i18n polyfill |
Thanks @dyingangel666, that was helpful. |
We have been using the angular-cli
ng xi18n
for our project with much success. I just setup our system to use the runtimeI18n
service and was able to get it working in both JIT for development server and the AOT for our released code.On thing I ran into was that I noticed the main bundle size grew dramatically. After looking at it I found that our entire xlf file was embedded in the javascript adding over 500K. Currently our project only has a couple of runtime translations so 99% of the embedded file is only used at compile time.
I realize that this project is a temporary solution until this feature is incorporated into the existing translation stuff, but I had a few questions:
The text was updated successfully, but these errors were encountered: