Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global require function vs. module require function #1505

Closed
ORESoftware opened this issue Mar 9, 2016 · 1 comment
Closed

Global require function vs. module require function #1505

ORESoftware opened this issue Mar 9, 2016 · 1 comment

Comments

@ORESoftware
Copy link

I just asked this question on SO, and hoping a definitive answer might be had there, but if the one and only James Burke could answer it himself here or on SO that might be helpful:

http://stackoverflow.com/questions/35902490/requirejs-difference-between-global-require-and-module-require

the question is:

I have been wondering this for a long time, using RequireJS, is there actually a difference between the global require function and the require function that is passed to a module like so:

define(function (require) {
    // require === window.require ?
});

I have read through the RequireJS docs a number of times, and I don't remember ever learning if there is a significant difference between the two functions. However, that being said, it seems reasonable to believe that they are different somehow, since if they were the same, there would be no need to pass the function to the module (?)

@jrburke
Copy link
Member

jrburke commented Mar 9, 2016

They are different, the main thing is that the local require knows how to resolve './relative' dependency IDs relative to the module ID asking for the dependency..

The global one cannot do that. The global one has .config() on it, can be used to configure the loader. Those are the main differences.

Closing as a discussion ticket, feel free to continue discussion here.

@jrburke jrburke closed this as completed Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants