-
Notifications
You must be signed in to change notification settings - Fork 27
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
Error: No formatters or parsers has been provided, when production is 'true'. #10
Comments
+1, I'm facing the same issue |
Hi, thanks for filing this issue. I could not reproduce it. I have cloned Please, could you describe the steps you are taking in more details? Also, note that in the webpack config, we have the following code below, which is slightly different than the one you posted, which might suggest it's good to double check you have up-to-date example. new GlobalizePlugin({
production: options.production,
developmentLocale: "en",
supportedLocales: [ "ar", "de", "en", "es", "pt", "ru", "zh" ],
messages: "messages/[locale].json",
output: "i18n/[locale].[hash].js"
}) |
Hi @rxaviers I pasted my dependencies from packages.json. If it makes any difference, my build kinda stalls at around 50% for a good few seconds then continues until this error comes up. I also tried to do a build with just 'en' locale but no luck. This error is persistent. I've pretty much tried any configuration I can think of including different release candidates.
|
Just in case, I tried with the messages key included. Still same result. @adros , I thought I was the only one, so bummer you're getting that error but I'm glad I'm not alone. |
@rxaviers I just reread your comment - the problem is not with globalize itself. Its with my application and the use of globaalize webpack plugin. When I build MY application with production:true in the GlobalizePlugin config then I get that error. Globalize itself is fine I'm sure |
Well, I have probably found the issue:
(which is corresponding to the error message 'No formatters or parsers has been provided'.) As soon as I add this code somewhere in the application, it starts working. But when I use globalize with react (which is obviously also @harel's situation), my application may really not have any |
But when I check the output in 'release' mode, maybe this plugin is not suitable for usage with react-globalize, because only those messages get to 'globalize-compiled-data', which are used directly by a Globalize method. Is it true? |
I have end up with the same issue when I use yours What I really want to do, is just use globalize with webpack. And I have not succeeded without yours plugin. But the plugin seems to do more than I want, it tries to analyse the code and extracts only used messages. Which makes unable to write code like this one:
because the compilation fails... Is it possible to skip this advanced features? |
I can confirm the error goes away after using @adros trick of putting a formatMessage somewhere. The build completes without error. However, that means that 'messages' are not optional, they are required. so this fails :
but this works:
And as well, I don't get the |
The json parsing errors appear on dev as well.
|
Sorry, i had production flag set to false when I tested just now. I tested again with production set to true, and it works still. The message files get bundled up in my app.js file though and not in the i18n directory as I specified in the output property. |
Ok I resolved part of this: |
|
the only thing I've done while having this problem is adding the plugin to my webpack config as described above, excluding the messages key. On dev mode it worked fine. But when setting production to true and running npm run build it failed. That is, until I tried the trick above which resolved it (i.e., adding messages and a formatMessage somewhere). Since then I've gone all in on globalizer and now am using the messages module and things are working fine. I'm not really sure how to dilute my app into a working 'failing' example at this point. |
Gotcha, this error shows up when no Globalize code is being used in the source code. |
I'm having the same issue with a webpack and react project. |
It seems as if the globalize-compiler is not able to figure out which formatters are used when the JS code is actually compiled by babel... |
@matthiasfeist if you have a formatter being used in your code, you have a different issue. Please, file a new issue with context. Also make sure you have Globalize 1.1.x in place. |
Thanks for the response. It was actually the issue with a version conflict 👍 thanks for the heads up! |
Excellent and you're welcome. |
I'm having the exact same issue. Using globalize with react-globalize. I am not using the message component. |
@lochstar do you use any Globalize function or react-globalize component? |
The only Globalize function I'm using is Globalize.locale(). I'm also using FormatCurrency, FormatDate, FormatNumber & FormatRelativeTime. |
Since you're using react-components this bug shouldn't affect you. You should set the default locale via your webpack config, not |
It's set via webpack config as well. I use If I remove the call, the error still persists when trying to build for production. |
Hm, ok. So, please file a separate ticket providing a reduced example. |
I've determined the following: include So production build works fine in both cases, as long as there's a direct call to Any ideas? Is this a |
+1 same here |
I really want to help you all, but it seems we're collecting so many different things for this issue. This issue is supposed to track a bug that shows up when trying to use the plugin while no Globalize code is being used in the source code. PS: react-globalize uses Globalize under the hoods, so using react-globalize messages and/or Globalize messages (.formatMessage) is equivalent. |
If you have problems with the react-globalize-plugin, please file an issue on rxaviers/react-globalize-webpack-plugin. I have provided a react-globalize example here, so please use this example as a baseline for yours. File the issue with an example in place (feel free to file a PR with the example then). |
If you have problems with this plugin (globalize-plugin) and it isn't the bug defined by this issue (using this plugin while no Globalize or react-globalize code is being used in the source code), please file a separate issue including an example. You can use this example as a baseline for yours. If you are experiencing the bug defined here, PRs are welcome. The fix shouldn't be hard. I can provide assistance. |
it also appears that in production mode that the require literally needs to be tied to a variable named "Globalize" in order for this error message to not appear. i.e.: var Globalize = require( "globalize" ); will succeed, but: var i18n = require( "globalize" ); will fail with the "Error: No formatters or parsers has been provided" message |
@AppSorcery you're correct, but this is a separate issue. The globalize-compiler is still pretty naive on that regard. It simply checks for |
@lochstar, @brenwell, @AppSorcery, you could have experienced this bug react-globalize-webpack-plugin#14. |
I've also had the same issue with production build It will work if I add the following somewhere in the app! Globalize.formatMessage("someMessage"); Its actually very annoying issue since the workaround basically means we have to add lines in the code to call to formatMessage API for every single entry in our .JSON files FYI: we are not using react-globalize |
Hi! Any new on this issue? I have the same problem |
Sorry for beating a dead horse, but we are seeing this issue as well when building our app using webpack with production flag set to true:
Our app doesn't use messaging and just uses the number parsing feature of globalize.
We are including globalize with:
Any suggestions? |
This definitely needs fix. PRs are welcome. I can provide assistance. |
@rxaviers hey, thanks for the quick reply. I see that dynamic locale loading has been brought up relating to this issue and was curious if you have a recommended way of doing that in an npm-webpack environment. The current example app with npm and webpack is really just good for one language but doesn't really do anything for those of us with use cases involving language pickers, etc. You've mentioned writing a custom {cldr: fn()} in the webpack config but does that mean if we want to select between 5 locales in the language picker, we'd need to pre-load all 5 locales in globalize? |
I have the same problem. |
@gehsekky no you wouldn't pre-load all 5 locales (into the browser all at once), you would look at the request headers (accepts language, e.g.) or some parameter you define in your request and load just that one locale (which would contain all of your localized messages including the localized text options for your language picker). then if the user selects a different locale you change the header or parameter and perform a new request (you could try and do something clever and fetch the new language bundle from a cdn over ajax and completely update the client without hitting the server...but i haven't tried it yet). |
Same EXACT issue with my code. If set to production mode, you get the error mentioned in the title. Seems like they are not going to fix this; apparently the issue has been around for two years now. |
Same problem, I am using |
This is the most annoying issue :) Perhaps we could simply catch that exception (thrown by globalize-compiler) and |
@darincardin and @casey-speer, may you push a sample repo with your issue at hand? I'll be happy to take a look and fix it. |
What I'd like to happen is that if import NumberFormatter from 'myFormatterComponents/number';
const myComponent = ({number}) => (<span> Look at this number: <NumberFormatter value={number} /></span>); and in a separate npm module import numberFormatter from 'myFormatters/number';
export const NumberFormatter = ({value}) => (<span>{numberFormatter(value)}</span>); finally in another npm module import Globalize from 'globalize';
export const numberFormatter = (value) => { return Globalize.formatNumber(value) }; I just want to drop in Does this make sense or is it unreasonable? I think for this case it's not a 'useless' inclusion of the plugin, just that the |
@casey-speer I get it. May you create a q&r sample repo? It will be much easier. |
Hi @casey-speer, this requires extra smarts to the globalize-compiler. Feel free to express your thoughts on how you think that could be doable. Specially, please read this globalizejs/globalize-compiler#10. Having said that, that seems a different topic and should be discussed elsewhere, not in this thread. Feel free to file an issue in globalize-compiler with your thoughts. Thanks. |
@diligiant @rxaviers Yes I think this does turn out to be off-topic. I've read through that issue and a lot of the |
Having kind of the same issue as well..
However, adding a formatting function like Globalize.formatMessage("someMessage"); does not help. My webpack config looks like
Versions:
|
Following the examples provided, using globalize-webpack-plugin 0.2 and globalize 1.1.0-rc.7 (as well as rc.5 and rc.6), when setting
production:true
I'm getting the following error below:Config
Error at
npm run build
The text was updated successfully, but these errors were encountered: