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

Expose module.uri for AMD modules #2386

Closed
m-nic opened this issue Mar 2, 2022 · 0 comments · Fixed by #2485
Closed

Expose module.uri for AMD modules #2386

m-nic opened this issue Mar 2, 2022 · 0 comments · Fixed by #2485

Comments

@m-nic
Copy link

m-nic commented Mar 2, 2022

Description of Proposed Feature

It should be possible for AMD modules to access their URI as with requireJS (see doc).

The implementation would be quite simple:
https://github.com/systemjs/systemjs/blob/main/src/extras/amd.js#L43

    return [amdDefineDeps, function (_export, _context) {
        // expose the url 
       module.uri = _context.meta.url;

      _export({ default: exports, __useDefault: true });
      return {....}

In the client code:

define(['module'], (module) => {
    console.log(module.uri)
})

In what way would you use it?

The idea is to also allow AMD modules to resolve their path and load their own assets.
This was at some point briefly mentioned in #1939.

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 a pull request may close this issue.

1 participant