globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Upgrade app-npm example to latest Webpack version #794

Closed OsmHydrant closed 6 years ago

OsmHydrant commented 6 years ago

What I did:

Details about faulty order workaround

By default the index.html would have contained those JS dependencies: vendor, main and finally all the globalize files like i18n/en. This is a problem, as i18n/en is required to be inserted before main. I'm sure this can to be solved within the globalize-webpack-plugin, but I was unable to understand its internals.

Remaining issue

Switching locale cannot be done by just replacing i18n/en by e.g. i18n/de as this causes the following Webpack error in the browser: Uncaught TypeError: Cannot read property 'call' of undefined

However if you keep the i18n/en dependency and just add another one below, it seems to work as the latter de overrules the former en:

<script type="text/javascript" src="vendor.08cec2a19c5b5399ed89.js"></script>
<script type="text/javascript" src="i18n/en.0153a1841b708266fe75.js"></script>
<script type="text/javascript" src="i18n/de.0153a1841b708266fe75.js"></script>
<script type="text/javascript" src="main.df3833cb62cd7f4b527a.js"></script>

Since this is contradictory behavior to the previous version, I'm sure there must be a better solution within globalize-webpack-plugin.

jsf-clabot commented 6 years ago

CLA assistant check
All committers have signed the CLA.

rxaviers commented 6 years ago

Sorry for the long delay reviewing your PR

rxaviers commented 6 years ago

Thank you @OsmHydrant