# Configurable (per client) modules

**URL:** <https://discourse.aurelia.io/t/configurable-per-client-modules/1713>\
**Category:** Best Practices\
**Created:** [October 9, 2018, 12:21pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713 "2018-10-09T12:21:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![krisc-informatica](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@krisc-informatica](https://discourse.aurelia.io/u/krisc-informatica)\
**Post date:** [October 9, 2018, 12:21pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/1 "2018-10-09T12:21:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![djedi](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/djedi/32/312_2.png) [@djedi](https://discourse.aurelia.io/u/djedi)\
**Post date:** [October 9, 2018, 7:31pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/2 "2018-10-09T19:31:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rhassler](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/rhassler/32/194_2.png) [@rhassler](https://discourse.aurelia.io/u/rhassler)\
**Post date:** [October 9, 2018, 8:53pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/3 "2018-10-09T20:53:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [October 9, 2018, 9:07pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/4 "2018-10-09T21:07:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rhassler](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/rhassler/32/194_2.png) [@rhassler](https://discourse.aurelia.io/u/rhassler)\
**Post date:** [October 9, 2018, 9:29pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/5 "2018-10-09T21:29:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [October 9, 2018, 9:47pm UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/6 "2018-10-09T21:47:38Z")

</div>

@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

```auto
"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';`.

---

<div class="post-metadata">

**Author:** ![krisc-informatica](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@krisc-informatica](https://discourse.aurelia.io/u/krisc-informatica)\
**Post date:** [October 10, 2018, 6:17am UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/7 "2018-10-10T06:17:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [October 10, 2018, 9:05am UTC](https://discourse.aurelia.io/t/configurable-per-client-modules/1713/8 "2018-10-10T09:05:35Z")

</div>

Have a look of [The easy way to customize child router based on parent router param](https://discourse.aurelia.io/t/the-easy-way-to-customize-child-router-based-on-parent-router-param/768)
