4

Ignoring the fact that this might not be a good idea is it possible to get requirejs to reference one library using two different paths i.e

require.config({
    paths: {
        'ko': '../Lib/knockout-2.1.0.debug',
        'knockout': '../Lib/knockout-2.1.0.debug',
    }
});

or possibly some other way? Currently its complaining

The reason is we have some external libraries that have external dependancies on 'knockout' where as we use 'ko'

1 Answer 1

5

It sounds like a map configuration is a better approach here. If you have modules that require 'ko' but others require 'knockout', then simply map 'ko' to 'knockout' for your modules.

require.config({
    paths: {
        'knockout': '../Lib/knockout-2.1.0.debug',
    },
    map: {
        '*': { 'ko': 'knockout' }
    }
});

And if only certain module names need the remapping, replace "*" with module name in the above example.

Or, if by "where as we use 'ko'" you also mean window.ko, you can do this instead:

require.config({
    paths: {
        'knockout': '../Lib/knockout-2.1.0.debug',
    }
});

define('ko', ['knockout'], function (punch)
{
  window.ko = punch;
  return punch;
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.