0

Require.js takes an optional config. Is it possible to map a path to an existing variable?

require.config({
    "paths": {
        "jquery": "../my/path/to/jquery"
    }
});

However, there is a case where I don't actually need jquery but a library thinks it does. So I need to include jquery but it doesn't actually use it. Actually storing the jquery file is bloat. So I want to map require("jquery") to function() {}. Is there any way to do this?

1 Answer 1

1

You don't need to set a paths for jquery for what you are trying to do. What you could do is add a fake jQuery module just before your call to require.config:

define('jquery');

This defines a jquery module that has an undefined value. If your premiss that you are using a library that requires jQuery but does not actually use it is true, then this will work.

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.