Feature request: requirejs Mutliversion configuration support
- Dominant language
- JavaScript
- Stars
- 402
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
**I'm submitting a feature request**
- **Library Version:**
0.17.0
**Please tell us about your environment:**
- **Operating System:**
Windows 10
- **Node Version:**
4.4.3
- **NPM Version:**
3.10.6
- **Browser:**
all
- **Language:**
ESNext
**Current behavior:**
Aurelia CLI uses requre loader, supporting limited loader configuration options.
**Expected/desired behavior:**
Allow [Multiversion Support](http://requirejs.org/docs/api.html#multiversion) configuration.
In `aurelia.json` allow specifying `context` that will be appended to the `loaderConfig` object that is passed to `require.config()`.
In addition allow specifying `contextGlobalObject` configuration parameter in `aurelia.json`
- **What is the expected behavior?**
In case `context` is specified `require.config()` will return require object to be used by loader.
So for multiversion to to be useful, we need a way to pass the object to the loader.
Since the [loader-default](https://github.com/aurelia/loader-default/blob/master/src/index.js) does not support usage of custom require object. It would be great to allow the developers to still use the multiversion functionality by implementing custom loader.
One quick (and dirty) solution could be to provide additional configuration for `aurelia.json`, for example `contextGlobalObject` that will be used as name for returned require object.
Aurelia cli can than perform the following when prepending the `require,js` script:
```
window[contextGlobalObject] = require.config({...});
```
It will allow implementing custom loader that will use it [here](https://github.com/aurelia/loader-default/blob/master/src/index.js#L136):
```
window[contextGlobalObject](['require', moduleId], resolve, reject);
```
- **What is the motivation / use case for changing the behavior?**
Support running multiple applications that use different `baseUrl` (Domains), module versions, etc, on single page. Each application will have it's own separate "context".
Contributor guide
Assessment
This issue has not been assessed yet.