Parameterizing the content of the browser package

I have a project built (bundled) with a browser. It supports some functionality for different locales (different languages). Currently all locales are loaded with commonJS

require

inline:

exports.a = require('./a') exports.b = require('./b') exports.c = require('./c') ...

but as you would expect, the package gets very large and a typical user only uses one locale at a time. The point is to parameterize the bundle in some way. The question is how to do it .

Most likely I would like to specify an input parameter with a list of locales, generate a node module that will only require the selected locales and start scrolling against it. But that's a nasty brute force looking for something else.

These are some conversions like globify that allow you to dump selected filepath wildcards. But I'm not sure if I can use it in this case.

There is also partitioning in the browser: factor-bundle and partition-bundle. In this case, I was analyzing the partitioning: create a locale map that can be loaded at runtime in the browser. But haven't tried it.

I would be grateful for what is a good solution in this case.

+3


source to share





All Articles