Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack Globalize fails build when set to production mode: No formatters or parsers provided

I'm working on a React/Webpack/Globalize app. In development mode things are ok-ish (though Globalize insists on compiling all locales instead of the one i have selected but that's another question for another day).
However, when I'm setting production: true in my webpack config, I'm getting the following error when running npm run build

> webpack --config webpack.prod.config.js

/opt/app/ui/node_modules/globalize-webpack-plugin/GlobalizeCompilerHelper.js:72
      throw e;
            ^
Error: No formatters or parsers has been provided

I was under the impression the globalize webpack plugin is meant to handle precompilation. Any idea why I'm seeing this error? When I'm setting production: false things compile fine.

My plugin setup is:

new GlobalizePlugin({
            production: true,
            developmentLocale: "en",
            supportedLocales: [ "en"],
            output: "i18n/[locale].[hash].js" 
        }),

When a file changes and webpack dev server rebuilds, I'm getting a LOT of these messages indicating recomplication of locales I am not using:

[461] ./~/cldr-data/main/es-PY/dateFields.json 15 kB {0} [optional]
[462] ./~/cldr-data/main/es-SV/dateFields.json 15 kB {0} [optional]
[463] ./~/cldr-data/main/es-US/dateFields.json 15 kB {0} [optional]
[464] ./~/cldr-data/main/es-UY/dateFields.json 15 kB {0} [optional]
[465] ./~/cldr-data/main/es-VE/dateFields.json 15 kB {0} [optional]
[466] ./~/cldr-data/main/es/dateFields.json 15 kB {0} [optional]

Nothing I try seems to get passed that problem.
Thanks

like image 256
Harel Avatar asked Dec 18 '15 17:12

Harel


1 Answers

As it stands, the messages key is not 'optional', but actually required. More than that, somewhere you need to 'prime' (for lack of a better word) the message formatter by calling Globalize.formatMessage("somekey") (where somekey exists in your lang file). All this is required when production is set to true.

As well, if you do set production to true, the output path must match an existing path in your source tree. If for example your code builds into /assets, the output path should be assets/i18n/[locale].[hash].js. Otherwise the i18n directory will not be created on build.

All this is derived from a discussion in the github repo:

https://github.com/rxaviers/globalize-webpack-plugin/issues/10

like image 104
Harel Avatar answered Nov 06 '22 17:11

Harel