Skip to content

Commit

Permalink
⚡ improvement(index): Suppress some warnings in production: smaller m…
Browse files Browse the repository at this point in the history
…in.js and performance gain. (#441) by @	exoego
  • Loading branch information
TATSUNO Yasuhiro authored and kazupon committed Oct 14, 2018
1 parent d75c90f commit 43931f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
}
})

if (hasPlaces && children.length > 0 && !everyPlace) {
if (process.env.NODE_ENV !== 'production' && hasPlaces && children.length > 0 && !everyPlace) {
warn('If places prop is set, all child elements must have place prop set.')
}

Expand Down
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ export default class VueI18n {
const linkPlaceholder: string = link.substr(2).replace(bracketsMatcher, '')

if (visitedLinkStack.includes(linkPlaceholder)) {
warn(`Circular reference found. "${link}" is already visited in the chain of ${visitedLinkStack.reverse().join(' <- ')}`)
if (process.env.NODE_ENV !== 'production') {
warn(`Circular reference found. "${link}" is already visited in the chain of ${visitedLinkStack.reverse().join(' <- ')}`)
}
return ret
}
visitedLinkStack.push(linkPlaceholder)
Expand Down Expand Up @@ -583,8 +585,10 @@ export default class VueI18n {

_n (value: number, locale: Locale, key: ?string, options: ?NumberFormatOptions): NumberFormatResult {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' && !VueI18n.availabilities.numberFormat) {
warn('Cannot format a Number value due to not supported Intl.NumberFormat.')
if (!VueI18n.availabilities.numberFormat) {
if (process.env.NODE_ENV !== 'production') {
warn('Cannot format a Number value due to not supported Intl.NumberFormat.')
}
return ''
}

Expand Down

0 comments on commit 43931f5

Please sign in to comment.