use-intl 2.10.1 → 2.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,9 @@ function resolvePath(
24
24
  ) {
25
25
  if (!messages) {
26
26
  throw new Error(
27
- __DEV__ ? `No messages available at \`${namespace}\`.` : undefined
27
+ process.env.NODE_ENV !== 'production'
28
+ ? `No messages available at \`${namespace}\`.`
29
+ : undefined
28
30
  );
29
31
  }
30
32
 
@@ -35,7 +37,7 @@ function resolvePath(
35
37
 
36
38
  if (part == null || next == null) {
37
39
  throw new Error(
38
- __DEV__
40
+ process.env.NODE_ENV !== 'production'
39
41
  ? `Could not resolve \`${key}\` in ${
40
42
  namespace ? `\`${namespace}\`` : 'messages'
41
43
  }.`
@@ -89,7 +91,9 @@ export function getMessagesOrError<Messages extends AbstractIntlMessages>({
89
91
  try {
90
92
  if (!messages) {
91
93
  throw new Error(
92
- __DEV__ ? `No messages were configured on the provider.` : undefined
94
+ process.env.NODE_ENV !== 'production'
95
+ ? `No messages were configured on the provider.`
96
+ : undefined
93
97
  );
94
98
  }
95
99
 
@@ -99,7 +103,7 @@ export function getMessagesOrError<Messages extends AbstractIntlMessages>({
99
103
 
100
104
  if (!retrievedMessages) {
101
105
  throw new Error(
102
- __DEV__
106
+ process.env.NODE_ENV !== 'production'
103
107
  ? `No messages for namespace \`${namespace}\` found.`
104
108
  : undefined
105
109
  );
@@ -187,7 +191,7 @@ export default function createBaseTranslator<
187
191
  return getFallbackFromErrorAndNotify(
188
192
  key,
189
193
  IntlErrorCode.INSUFFICIENT_PATH,
190
- __DEV__
194
+ process.env.NODE_ENV !== 'production'
191
195
  ? `Insufficient path specified for \`${key}\` in \`${
192
196
  namespace ? `\`${namespace}\`` : 'messages'
193
197
  }\`.`
@@ -231,7 +235,7 @@ export default function createBaseTranslator<
231
235
 
232
236
  if (formattedMessage == null) {
233
237
  throw new Error(
234
- __DEV__
238
+ process.env.NODE_ENV !== 'production'
235
239
  ? `Unable to format \`${key}\` in ${
236
240
  namespace ? `namespace \`${namespace}\`` : 'messages'
237
241
  }`
@@ -274,7 +278,7 @@ export default function createBaseTranslator<
274
278
  return getFallbackFromErrorAndNotify(
275
279
  key,
276
280
  IntlErrorCode.INVALID_MESSAGE,
277
- __DEV__
281
+ process.env.NODE_ENV !== 'production'
278
282
  ? `The message \`${key}\` in ${
279
283
  namespace ? `namespace \`${namespace}\`` : 'messages'
280
284
  } didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`
@@ -71,7 +71,7 @@ export default function createIntl({
71
71
  if (!options) {
72
72
  const error = new IntlError(
73
73
  IntlErrorCode.MISSING_FORMAT,
74
- __DEV__
74
+ process.env.NODE_ENV !== 'production'
75
75
  ? `Format \`${formatName}\` is not available. You can configure it on the provider or provide custom options.`
76
76
  : undefined
77
77
  );
@@ -153,7 +153,7 @@ export default function createIntl({
153
153
  now = globalNow;
154
154
  } else {
155
155
  throw new Error(
156
- __DEV__
156
+ process.env.NODE_ENV !== 'production'
157
157
  ? `The \`now\` parameter wasn't provided to \`formatRelativeTime\` and there was no global fallback configured on the provider.`
158
158
  : undefined
159
159
  );
@@ -67,7 +67,7 @@ export default function createTranslatorImpl<
67
67
  if (typeof result !== 'string') {
68
68
  const error = new IntlError(
69
69
  IntlErrorCode.FORMATTING_ERROR,
70
- __DEV__
70
+ process.env.NODE_ENV !== 'production'
71
71
  ? "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})"
72
72
  : undefined
73
73
  );
@@ -24,7 +24,7 @@ export default function IntlProvider({
24
24
  messages,
25
25
  ...contextValues
26
26
  }: Props) {
27
- if (__DEV__) {
27
+ if (process.env.NODE_ENV !== 'production') {
28
28
  // eslint-disable-next-line react-hooks/rules-of-hooks
29
29
  useEffect(() => {
30
30
  if (messages) {
@@ -6,7 +6,7 @@ export default function useIntlContext() {
6
6
 
7
7
  if (!context) {
8
8
  throw new Error(
9
- __DEV__
9
+ process.env.NODE_ENV !== 'production'
10
10
  ? 'No intl context found. Have you configured the provider?'
11
11
  : undefined
12
12
  );