-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
base: main
Are you sure you want to change the base?
Conversation
@@ -1,4 +1,4 @@ | |||
/* globals requirejs, require */ | |||
/* globals requirejs, require, loader */ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'
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 */); | ||
} |
There was a problem hiding this comment.
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 */);
Fixes #629