svelte-i18n/docs/FAQ.md
Christian Kaisermann 69ec477ffd docs: ✏️ move docs out of wiki
2020-01-21 10:00:45 -03:00

824 B

'this' keyword is equivalent to 'undefined'

When using Rollup as a bundler, you're possibly seeing this warning. It's related to the output of the typescript compiler used to transpile the intl-messageformat package. In this case, it's harmless and you can learn to live with it on your terminal or teach your rollup to ignore this kind of warning:

// modified version of onwarn provided by sapper projects
const onwarn = (warning, onwarn) => {
  if (
    (warning.code === 'CIRCULAR_DEPENDENCY' &&
      /[/\\]@sapper[/\\]/.test(warning.message))
  ) {
    return
  }

  // ignores the annoying this is undefined warning
  if(warning.code === 'THIS_IS_UNDEFINED') {
    return
  }

  onwarn(warning)
}

export default {
  client: {
    ...,
    onwarn,
  },
  server: {
    ...,
    onwarn,
  },
}