Configurable (per client) modules


I am developing an application that will be installed individually for different environments (companies). How can I implement modules that are used for one client but not for an other one? Is there a way to configure what is bundled per client?

Thanks for any suggestion


Could you have a different base project per client and import your modules via npm?


Rather than using environments of dev and test, you could have environments of client1 and client2. Then in aurelia-project you could add a section for each client where you list the dependencies.


@rhassler Could you share an example? I am interested on your approach. Thx!


I don’t have an example. This idea came to me because I had recently been reading the aurelia-cli documentation.


@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';.


Thanks alot for these quick replies. At the moment I’m using a rather old version of aurelia with gulp and not cli. I’ll have to migrate…

The solution from @huochunpeng seems interesting to follow. I guess I can use child-routes to make client-specific routes?


Have a look of The easy way to customize child router based on parent router param