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 605 forks source link

Webpack not working without plugin ? #814

Open ButuzGOL opened 6 years ago

ButuzGOL commented 6 years ago

When comment out

new GlobalizePlugin({
  developmentLocale: "en",
})

i have webpack errors

RROR in ./node_modules/globalize/dist/globalize.js
Module not found: Error: Can't resolve 'cldr' in '/Users/butuzgol/Desktop/revvy-ui/docs/node_modules/globalize/dist'
 @ ./node_modules/globalize/dist/globalize.js 22:2-25:14
 @ ./node_modules/globalize/dist/globalize/unit.js
 @ ./node_modules/globalize/dist/node-main.js
 @ ./src/components/BadgeExamples.js
 @ ./src/App.js
 @ ./src/index.js

Is there any way to use without plugin ?

EdwardSalter commented 6 years ago

The module is written to primarily support AMD modules (require.js) by the looks and has a special mapping set in its build.

To fix this issue using webpack you can add this to your webpack.config.js:

      alias: {
        'cldr$': 'cldrjs',
        'cldr': 'cldrjs/dist/cldr'
      }

See this issue for more info: https://github.com/globalizejs/globalize/issues/603

voitsekhovskymax commented 5 years ago
      alias: {
        'cldr$': 'cldrjs',
        'cldr': 'cldrjs/dist/cldr'
      }

Thank you!