0

I have 2 modules A and B. Also I have 3 libs L1, L2 and L3.

Module A:

define(
    ['L1', 'L2'],
    function (L1, L2) { ... }
);

Module B:

define(
    ['A', 'L3'],
    function (A, L3) { ... }
);

Is i'm right that module B already have L1 and L2 libs in scope or I must reinclude these libs?

Module B:

define(
    ['A', 'L1', 'L2', 'L3'],
    function (A, L1, L2, L3) { ... }
);
1
  • why is this -1? I had the same question Commented Jul 30, 2013 at 20:59

1 Answer 1

2

If you want to use those libs in Modulue B you have to explicitly name them in your definition.

define(['A', 'L1', 'L2', 'L3'], function (A, L1, L2, L3) {

    // ...
});

If you don't want to use them this will be okay:

define(['A', 'L3'], function (A, L3) {

    // L1 undefined here
});
Sign up to request clarification or add additional context in comments.

3 Comments

Are you sure that L1 is undefined here?
yes, you can use A without problems, it has it's own references to L1 etc.. but L1 will be undefined in the scope of your define-function
Comment by Jasmine Hegman: L1 undefined, although its possible A could provide a means to access it (its loaded as a dependency of A which is a dependency of this script alongide L3).

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.