{"action":"created","issue":{"url":"https://api.github.com/repos/systemjs/systemjs/issues/1277","repository_url":"https://api.github.com/repos/systemjs/systemjs","labels_url":"https://api.github.com/repos/systemjs/systemjs/issues/1277/labels{/name}","comments_url":"https://api.github.com/repos/systemjs/systemjs/issues/1277/comments","events_url":"https://api.github.com/repos/systemjs/systemjs/issues/1277/events","html_url":"https://github.com/systemjs/systemjs/issues/1277","id":155884646,"number":1277,"title":"Question: synchronous System.locate, and counting on System._loader.loads at runtime","user":{"login":"joeldenning","id":5524384,"avatar_url":"https://avatars.githubusercontent.com/u/5524384?v=3","gravatar_id":"","url":"https://api.github.com/users/joeldenning","html_url":"https://github.com/joeldenning","followers_url":"https://api.github.com/users/joeldenning/followers","following_url":"https://api.github.com/users/joeldenning/following{/other_user}","gists_url":"https://api.github.com/users/joeldenning/gists{/gist_id}","starred_url":"https://api.github.com/users/joeldenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeldenning/subscriptions","organizations_url":"https://api.github.com/users/joeldenning/orgs","repos_url":"https://api.github.com/users/joeldenning/repos","events_url":"https://api.github.com/users/joeldenning/events{/privacy}","received_events_url":"https://api.github.com/users/joeldenning/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-20T04:25:18Z","updated_at":"2016-05-20T11:29:29Z","closed_at":null,"body":"1. After a module has been loaded, is there any way to get the address of a module in a synchronous fashion? It seems like the answer might be no (since SystemJS.locate returns a promise), but thought I'd check.\r\n\r\n2. Since I really need to get the address of a module synchronously, I've discovered that when a module is being instantiated (i.e., the function passed to `System.register()` is called but not yet the execute function) that SystemJS._loader.loads contains the load object for the module, complete with its address. How bad of an assumption is it for me to depend on that behavior?\r\n\r\n3. If 2) isn't a bad assumption already, I'd like to take it even a step further. It seems that during the instantiation of a module that one can find its address without even searching all the way through `SystemJS._loader.loads`. Instead, it seems that the first element in the array is always the load for the module. In other words, you don't have to find the correct load because `SystemJS._loader.loads[0]` is what you're looking for. How dirty is it to depend on that behavior, and can I count on it staying that way?\r\n\r\nExplanation:\r\nI just enhanced the Webpack plugin, [webpack-system-register](https://github.com/CanopyTax/webpack-system-register), to allow for dynamic, runtime computation of webpack's `output.publicPath`. The publicPath is set at runtime based on the URL address of the module that has been bundled with webpack/webpack-system-register.\r\n\r\nIn the process of building that, I realized that I really needed to have the address for the current Module in a synchronous fashion, since webpack expects the value synchronously. See [documentation](https://github.com/CanopyTax/webpack-system-register#configuration-options) and [code snippet](https://github.com/CanopyTax/webpack-system-register/blob/master/src/webpack-system-register.js#L150-L159) for further clarification."},"comment":{"url":"https://api.github.com/repos/systemjs/systemjs/issues/comments/220582215","html_url":"https://github.com/systemjs/systemjs/issues/1277#issuecomment-220582215","issue_url":"https://api.github.com/repos/systemjs/systemjs/issues/1277","id":220582215,"user":{"login":"rksm","id":467450,"avatar_url":"https://avatars.githubusercontent.com/u/467450?v=3","gravatar_id":"","url":"https://api.github.com/users/rksm","html_url":"https://github.com/rksm","followers_url":"https://api.github.com/users/rksm/followers","following_url":"https://api.github.com/users/rksm/following{/other_user}","gists_url":"https://api.github.com/users/rksm/gists{/gist_id}","starred_url":"https://api.github.com/users/rksm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rksm/subscriptions","organizations_url":"https://api.github.com/users/rksm/orgs","repos_url":"https://api.github.com/users/rksm/repos","events_url":"https://api.github.com/users/rksm/events{/privacy}","received_events_url":"https://api.github.com/users/rksm/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T11:29:29Z","updated_at":"2016-05-20T11:29:29Z","body":"I'm interested in the answers as well. Just wanted to add that a `System.trace = true` will populate `System.loads` on subsequent imports. In there you find the entries being loaded, complete with address and all."}}
{"actor":{"display_login":"rksm"}}