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

Add examples of what happens for relative require paths #343

Open
sigdestad opened this issue Oct 7, 2021 · 1 comment
Open

Add examples of what happens for relative require paths #343

sigdestad opened this issue Oct 7, 2021 · 1 comment
Assignees

Comments

@sigdestad
Copy link
Member

AFAIK this has a resolution pattern of some kind (locally first, then within /lib etc..)
https://developer.enonic.com/docs/xp/stable/framework/globals#require

@rymsha
Copy link
Contributor

rymsha commented Nov 16, 2021

It is said on the page you linked

If the path is relative then it will start looking for the file from the local directory

It also says

The function implements parts of the CommonJS Modules Specification

And one who is familiar with it can know that

Relative identifiers are resolved relative to the identifier of the module in which "require" is written and called.

So, it is explained at least twice how relative paths are resolved.

BTW, there is no lookup in anywhere else (/lib etc...) as it would be against CommonJS Modules Specification

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

3 participants