question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue i18n Advanced Optimization

See original GitHub issue

Hello, i just use this template and run it.

I can see a warning message in console.

image

vue-i18n.esm-bundler.js:46

You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.

Of course, we can turn off the warning like this.

// vite.config.ts
export default defineConfig({
  resolve: {
    alias: {
      "vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js",
    },
  },
})

Do we need set boolean literals to replace feature flag globals? (Sorry, i can not understand what do we need to do.)


In addition, I read the documentation of vue-i18n.

Improve performance and reduce bundle size with runtime build only

Should we add it as part of the vite template?

export default defineConfig({
  // ...
  alias: {
    'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
  },
})

If you need, I can create a PR for it.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
userquincommented, Jul 18, 2021

Just add these 2 options on VueI18n plugin, the plugin will change the module for you and so you don’t have to map/resolve its internals:

    // https://github.com/intlify/vite-plugin-vue-i18n
    VueI18n({
      runtimeOnly: true,
      compositionOnly: true,
      include: [path.resolve(__dirname, 'locales/**')],
    }),
1reaction
userquincommented, Jul 18, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimization - Vue I18n - Intlify
The use of this ES Module means that all locale messages have to pre-compile to Message functions. what this means it improves performance ......
Read more >
https://github.com/intlify/vue-i18n-next/edit/mast...
No information is available for this page.
Read more >
Performance optimization of vue-i18n - Medium
vue -i18n provides a compiler module that enables pre-translation of custom directive v-t , using the compilation hooking mechanism provided with ...
Read more >
Localization in Vue.js with vue-i18n - LogRocket Blog
The advanced localization techniques you can implement with Vue.js will help your web application reach a wider global audience.
Read more >
You are running the esm-bundler build of vue-i18n. It is ...
Now i am using this way to import the i18n, the warning is disapear import { createI18n } from 'vue-i18n/index'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found