Uppy: Reduce the final bundle size by filtering locales

Created on 15 Jul 2020  路  2Comments  路  Source: transloadit/uppy

Hi,

Just took a look at my final bundle composition and here it is:
image

In my case I would like to just keep 1-2 locales, without bringing all others in the deployment.

What's your recommended way to do so?

Thank you,

Question

All 2 comments

Can you show how you're importing Uppy? I don't think all the locales should be included by Uppy unless there is a bug.

If you only want a couple you can do:

import fr_FR from '@uppy/locales/lib/fr_FR'

and you should only get the french one.

Oh my bad!

I took a part of a Uppy Vue component on GitHub and they were doing something like:

  protected getLocale(): string | null {
    let lang = null;
    if (this.locale) {
      lang = require(`@uppy/locales/lib/${this.locale}`);
    }

    return lang;
  }

So this import is at runtime... so I guess without knowing the value during compilation, webpack brings everything into the bundle. Replacing by a "static" import outside component as you mentioned solved the problem.

Thank you @goto-bus-stop!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agreene-coursera picture agreene-coursera  路  4Comments

ogtfaber picture ogtfaber  路  4Comments

skunkwerk picture skunkwerk  路  3Comments

rrjanbiah picture rrjanbiah  路  3Comments

oyeanuj picture oyeanuj  路  3Comments