Skip to content

Dependency Tracing API #363

@guybedford

Description

@guybedford

Thanks so much again for your help yesterday - I've managed to get a trace function working now!

The gist is at - https://gist.github.com/4635908

There were a few hoops to jump through to get it working, so your code pointers were really useful in tracking these down. Mostly it worked out quite easily (thankfully!).

Ideally, this could be included as an API function at requirejs.trace when running through node. It would be a very useful API. Let me know if you'd like a pull request for integration at all.

There are a couple of issues with the tracing process at the moment, particularly with reference to the onResourceLoad API:

  1. Dependency maps for plugins are often provided unnormalized even though loading has completed. I had to manually check 'unnormalized' and then replace with prefix + '!' + name.
  2. Tracing cs! modules means writing specific code to check if there is a cs! prefix and if so, trace dependencies for without the prefix by adding a dummy dependency. Ideally this would be sorted by having the defined ID as the full ID not the name when using load.fetchText.
  3. Nested plugin calls (a!b!module/name) still don't normalize into the depth of the call, meaning traces aren't possible on any module which is a plugin of a plugin. This is probably a tricky one. The only use case I can see this affecting is with calls like is!mobile?cs!mobile-code. That might cause issues later when this is actually attempted, but for now it isn't too much of a critical use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions