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

Use loader aliases when using require invocations #634

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rajasegar
Copy link

Fixes #629

@@ -1,4 +1,4 @@
/* globals requirejs, require */
/* globals requirejs, require, loader */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should import require from require, then we'd get the one we want automatically

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @rwjblue I don't get it, can you please elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe he wants to to import require from 'require'

Comment on lines +474 to +479
let module;
if(loader.__aliases && loader.__aliases.require) {
module = window[loader.__aliases.require](normalizedModuleName, null, null, true /* force sync */);
} else {
module = require(normalizedModuleName, null, null, true /* force sync */);
}
Copy link

@jamesarosen jamesarosen Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a little more resilient if you extracted a variable:

const req = loader.__aliases?.require ? window[loader.__aliases.require] : require
const module = req(normalizedModuleName, null, null, true /* force sync */);

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

Successfully merging this pull request may close these issues.

Resolver does not honor the loader noconflict aliases
4 participants