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
Cannot build in --prod mode with registerLocaleData(fr); #21809
Comments
related: #21595 |
@ocombe I understand |
We have the same problem when we import It happens only after upgrading from v5.2.1 to v5.2.2 |
@rokerkony you shouldn't need to import "en" locale, it's included in Angular already. @adrienboulle thanks for the repro, looking into it. |
Ok I found the issue, when you import multiple locale files, they all have a function named "plural", and there's a name collision because of flat modules optimizations that the CLI does. |
This is a bug with Webpack's There is no available workaround in Angular CLI as far as I can tell. I'm not sure if this sort of bug will get a lot attention due to the low frequency, available workaround, and Webpack's focus on getting v4 out. My recommendation is that Angular replaces the empty array elements with |
this PR would fix it on our side: #20624 |
The fix has been merged into webpack, we need a new version published and then we need to publish a new version of the cli |
@ocombe Great thx :) |
true, it won't change anything though, since webpack is the blocker here |
Reverting your commit until then is not an option ? |
we will do something if it turns out that the webpack patch is nowhere close to be released, I've asked them, waiting for the release |
ok thx ! |
I'm waiting for this fix as well. I started noticing this error on a project that I run Angular 5.0.3 and Angular CLI 1.5.4, I tried updating to 5.2.1, 5.2.1 and Angular CLI 1.6.6 and still having issues. To me I can't get it working no matter which version I revert back to -- I'm not sure why. |
@marcuslind90 make sure to delete package-lock.json and to lock version in package.json (remove the |
Encountered the same problem
on:
I have added this to my {
...
"devDependencies": {
...
"webpack": "https://github.com/webpack/webpack.git#ddb1fad582bf1621840ae8a6e77488ca081695c4"
}
} |
@ocombe any update here? |
@alexabbott , according to ocombe's PR (#20624), you should modify your
I have tested this on my machine, and it works well. |
@alexabbott, i also just tried out @universonic suggestion and it worked. The bundle sizes are a bit larger but at least the code will compile in prod mode again. |
the code posted by @universonic fixes the issue but in my case the bundle size increased from 1.8 MB to 2.5 MB I guess due to the impossibility of applying tree shaking with commonjs modules |
Reverting to "@angular/common": "5.2.1" solved the problem. |
@ocombe I would like to know when the fix will be released? Is there a plan? |
Same here ... does not build when registerLocaleData is called. Timeframe for solution ? |
I have the same problem =/ |
The root issue should be fixed in the latest webpack release https://github.com/webpack/webpack/releases/tag/v3.11.0 . |
it will be resolved once the following PR lands in @angular/cli: angular/angular-cli#9604 |
Should this be closed? |
I don't have the error anymore with @angular/cli 1.7.4 |
I know this will probably get ignored but is there any chance that the "registerLocaleData" api just... disappear ? Seriously, everyone makes mistakes and i think this was a big one. First of all, why is "english" registered by default ? What kind of message is the framework conveying by this default setting ? That english is somehow more important than klingon ? Maybe, but I still think it is wrong. Also, about klingon, maybe I got that wrong, but can I load a language with any code I want ? It surely seems to not be the case as only the languages that the framework provide are accepted. I don't know anything about that or CLDR etc but it seems absolutely wrong to me that you need to accept that there is an exhaustive list of languages somewhere and you can only choose those. Why ? What if I want to load blarg of culture blorg 'bl-Blo' ? Don't tell me the language does not exist, why would you even need to know that ? Why do you even "care" ? This was so simple and convenient to use. Just load your map of keys-translations. Now this. Come on, revert this. It's stupid. |
I'm not super happy with the current English is the default because that's the most commonly used language in the world, and also Google is american. We needed one language by default to make it simpler to use the pipes when you don't care about i18n and just want them to work. You can use any code that you want, we've added an extra parameter to Also don't say that it's stupid if you don't provide an alternative. Be constructive, how would you prefer it to work? |
@ocombe I apologize for the last statement, I've been using angular and ngx-translate for a long time and I have always been very productive with them. I am just frustrated to see that we need to dedicate some time to register the languages dynamically at runtime (our users should be able to register the language they need in their app) and I don't see much value of doing so for something that was perfectly correct and maintainable previously in my opinion. As for English being the most commonly used language, not to be picky but that's actually wrong, mandarin would be the winner here. And Google being american, so what ? Our users won't even need english but french and spanish so I actually need to remove english from the i18n. About the alternative i think it is pretty simple. Don't do anything. Allow people to load their keys-translations like before and only propose the i18n files as opt in. I don't even like how the taxonomy of languages is done with "language" and "culture". I think it's great if people want to use it, but why is it forced on users, especially those who started their app a long time ago and just want to upgrade for better performance ? I am not even complaining about the issue that happened in AOT because of this change for which I also needed to make changes (I'm not using the cli we started our app with angular beta a long time ago). Anyway, now that it is done I would not go against my own complaint and ask to break things again. Especially since other than that i am more than pleased with the great work done by the framework. |
Hey :) |
@kavi87 when you build with the CLI you can do @rokerkony It's difficult to do because english is loaded at build time, and LOCALE_ID is a provider, it's only registered at runtime. One thing that I've been thinking of would be to never load english unless the i18n pipes are used and no LOCALE_ID is registered, it should be possible to find that out with the typescript transformers, or when we build with the CLI |
@ocombe Thanks for the pointer. For now i will register the languages we need explicitly as explained in the docs and make something to register additional lang if needed at application init. |
Hi guys how solved this problem with the registerLocaleData in app.module.ts??
|
Any solutions? |
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. |
I'm submitting a...
Current behavior
when building in prod mode with this:
the build whit the --prod option will fail with the stack:
Expected behavior
should build with
--prod
Angular version:
@angular/cli: 1.6.6
@angular/*: 5.2.2
Others:
works with @angular/*: 5.2.1
reproduction: https://github.com/adrienboulle/test-prod-build
I have started a new project with the
ng cli
and I have just added theregisterLocaleData(fr)
thing.I've tracked the issue to this commit:
71f9eaa (it works again when I modify juste
/common/locales/fr.js
to it's previous state)The text was updated successfully, but these errors were encountered: