Skip to content

Expose module.uri for AMD modules #2386

@m-nic

Description

@m-nic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions