@krisc-informatica if I understand you correctly, you have all features in local src, but only want to turn on certain feature set based on client’s subscription. You can bundle all modules for every client, but it seems not optimal to ship unused modules to a client.
If you use cli+requirejs setup, one easy solution I can think of, is to use code splitting on all feature sets, like this:
Note I use simplified glob on js that only works with latest cli v1.0.0-beta.1
"bundles": [
{
"name": "feature-one-bundle.js",
"source": {
"include": ["**/src/feature/one/**/*.{js,css,html}"]
}
},
{
"name": "feature-two-bundle.js",
"source": {
"include": ["**/src/feature/two/**/*.{js,css,html}"]
}
},
{
"name": "app-bundle.js",
"source": {
"include": ["**/*.{js,css,html}"]
}
}, //...
Note there is a trick in my config, I put feature-one-bundle.js
above app-bundle.js
, so I don’t have to write verbose "exclude"
list for app-bundle.js
.
Now you have separated bundle file per feature, you can have a deployment script that only copies needed bundle files to certain client.
Be careful, if client-a doesn’t use feature/one
, you need to make sure at runtime that no code will trigger import foo from 'feature/one/foo';
.