-1

Calling require.js before knockout.js throws the following message:

Uncaught ReferenceError: ko is not defined

Assuming I have knockout.js at the very top of the combined file, I have this:

<script type="text/javascript" src="/bower_components/requirejs/require.js"></script>
<script type="text/javascript">
    requirejs.config({
        paths: {
            text: '/bower_components/text/text'
        },
    });

    requirejs([
        '/bower_components/text/text.js'
    ]);
</script>
<script type="text/javascript" src="/js/dist/combined.min.js"></script>
Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • What *else* than `knockout.js` is in the `combined.min.js` file? – Louis Sep 15 '16 at 16:42
  • Nevermind, I ended up getting rid of require.js and creating my own component loader... much easier and I saved around 25Kb of crap. Life is beautiful again! – Alvaro Sep 15 '16 at 16:43

1 Answers1

2

When Knockout detects RequireJS, it doesn't create a global ko object but expects you to use define to get the object.

Michael Best
  • 16,623
  • 1
  • 37
  • 70