-
Notifications
You must be signed in to change notification settings - Fork 12k
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
v9: ng add @angular/localize doesn't fix error #16890
Comments
I had the same issue, I had to run it twice for it to add it. |
@wardbell Thanks for answering. But was the issue resolved for you, once the import statement was available? Because as mentioned in the description, for me it's not resolved even when adding it manually. |
Hi @julmot, thanks for reporting the issue. Could you please provide a small repro (in a form of Github repo), so that we can perform further investigation? Thank you. |
@andreaswissel Thanks for your reply. Luckily I could indeed reproduce it in a minimal repo. I've removed everything that is unnecessary from a real life application where I've encountered the issue. There might be some fragments in the Please head over to the following repository: https://github.com/julmot/angular-localize-error NOTE: As you can see in the 4 available commits I've created one commit for:
As you can see in the 3rd commit, the import statement is not generated automatically. And even with manually adding the import statement – it's still resulting in the same error in the browser console. Run |
So the problem is that when you specify a specific locale for a CLI build it will actually replace the You can see this by stepping into the code and looking at polyfills.js file, which contains the following:
I think the correct solution to this issue is for the CLI to avoid replacing the |
There appears to be several different elements involved in this situation. In regards to the reproduction (thank you for a minimal reproduction), some of the Angular CLI migrations are not performed on the configuration file due to the usage of a third party builder. The Angular CLI does not know how to interpret the options and behavior of a third-party builder. As a result, third-party builders may need to be updated separately (either manually or via migrations if provided by the builder) to allow them to function properly with Angular 9.0 and/or align them with 9.0 best practices. Starting with Angular 9.0, Ahead of Time (AOT) compilation is enabled for both development and production configurations. The new compiler provides significant performance improvements for AOT. AOT also provides improved error and diagnostic reporting at build time and is now recommended for use in development. The use of the third-party builder is also the reason As to the situation of using localization in combination with JIT mode, there are also several concerns to consider. One is the localize polyfill. The current behavior can definitely be changed to account for JIT usage. However, I think the larger concern is user expectations of attempting to use localization with JIT. Currently without AOT enabled, the translations present in the application will not be translated to the locale specified and will instead remain in the source locale. For locales with defined translations, I think a build warning may be useful to indicate the expected outcome of such a build. |
Hello @petarblazevski and @clydin, Thanks for your feedback! I have just two questions concerning your answers:
Which builder do you mean, xliffmerge? If so, I'm confused, because this builder is completely separate and I've not enhanced or manipulated any of the built-in builders, just configured them. Because of that and because this also has to be run separately, I don't understand why this could break Angular's migration?
What would be necessary to workaround the solution until an official fix, and would there be necessary changes for it to work with an official fix? Thanks in advance! |
As to the localize issue, the easiest way to fix the issue would be to enable AOT. Always using AOT is now the recommended best practice. This also has the advantage of creating translated builds in development mode including when using |
@clydin Thank you very much for your answer.
Indeed, in the example repository that's true. However, as this is only a minimal example I've removed the other reason why I've needed to extend Angular's webpack configuration: To configure alias paths. I'm importing a shared components library that we're using component-wide and this component library uses the
I have to confess, I'm now even more confused 😄 However, now I could migrate to Angular v9. Thank you! 🎆 |
TypeScript's path mapping can be used as a replacement for resolve.alias. For the Angular CLI, path mapping affects all TS and JS files processed by Webpack.
|
Thanks @clydin for fixing this issue. In terms of removing
So, if I understood you correctly the migration in |
@julmot Can you provide an example of the stylesheet usage? Are you using For |
@clydin Thanks for your reply. Yes you're right and I'm already using it to import a file "_common.scss" from the |
@debender495 - it is difficult to say from your stack trace but I am confident that your error is not related to this issue. Please create a new issue with a reproduction of your problem, which we can then investigate. |
@petebacondarwin created an issue, but unfortunately it's closed without any resolution. ng test fails in angular 9 |
The best way to do this is by using Angular CLI: If you don't want to go through the CLI approach then you can manually enter the import statement in the polyfills.ts file. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
The issue is caused by package @angular/localize
Is this a regression?
Yes, the previous version in which this bug was not present was: Angular v8
Description
After running
ng update @angular/core @angular/cli
on an Angular v8 application theng serve
command ran without errors, but I've seen the following error in the browser consoleas described in the migration guide.
Therefore I've executed
ng add @angular/localize
like described. But:🔥 Exception or Error
🌍 Your Environment
Angular Version before updating:
Angular Version after updating:
The text was updated successfully, but these errors were encountered: