Always require a plugin to be loaded
- by axon
I am writing an application with RequireJS and Knockout JS. The application includes an extension to knockout that adds ko.protectedObservable to the main knockout object. I would like this to always be available on the require'd knockout object, and not only when I specify it in the dependencies. I could concat the files together, but that seems that it should be unnecessary.
Additionally, I can put knockout-protectedObservable as a dependency for knockout in the requirejs shim configuration, but that just leads to a circular dependency and it all fails to load.
Edit:
I've solved me issue, but seems hacky, is there a better way?
-- Main.html
<script type="text/javascript" src="require.js"></script>
<script type="text/javascript">
require(['knockout'], function(ko) {
require(['knockout-protectedObservable']);
});
</script>
-- knockout-protectedObservable.js
define(['knockout'], function(ko) {
ko.protectedObservable = { ... };
});