Skip to content

Commit

Permalink
fix(@formatjs/intl): only warn about non-AST messages during initiali…
Browse files Browse the repository at this point in the history
…zation, fix #2258
  • Loading branch information
longlho committed Nov 21, 2020
1 parent 709225c commit 36e40f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
13 changes: 13 additions & 0 deletions packages/intl/src/create-intl.ts
Expand Up @@ -69,6 +69,19 @@ export function createIntl<T = string>(
)
);
}

const firstMessage = config.messages
? config.messages[Object.keys(config.messages)[0]]
: undefined;
if (
config.defaultRichTextElements &&
firstMessage &&
typeof firstMessage === 'string'
) {
console.warn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
Please consider using "@formatjs/cli" to pre-compile your messages for performance.
For more details see https://formatjs.io/docs/getting-started/message-distribution`);
}
return {
...resolvedConfig,
formatters,
Expand Down
11 changes: 0 additions & 11 deletions packages/intl/src/message.ts
Expand Up @@ -126,17 +126,6 @@ export function formatMessage<T>(
return message[0].value;
}

if (
!values &&
message &&
typeof message === 'string' &&
defaultRichTextElements
) {
console.warn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
Please consider using "@formatjs/cli" to pre-compile your messages for performance.
For more details see https://formatjs.io/docs/getting-started/message-distribution`);
}

// IMPORTANT: Hot path straight lookup for performance
if (
!values &&
Expand Down

0 comments on commit 36e40f4

Please sign in to comment.