{"action":"created","issue":{"url":"https://api.github.com/repos/requirejs/almond/issues/101","repository_url":"https://api.github.com/repos/requirejs/almond","labels_url":"https://api.github.com/repos/requirejs/almond/issues/101/labels{/name}","comments_url":"https://api.github.com/repos/requirejs/almond/issues/101/comments","events_url":"https://api.github.com/repos/requirejs/almond/issues/101/events","html_url":"https://github.com/requirejs/almond/issues/101","id":55171355,"number":101,"title":"normalize fails for relative imports with prefixes","user":{"login":"rockymeza","id":21784,"avatar_url":"https://avatars.githubusercontent.com/u/21784?v=3","gravatar_id":"","url":"https://api.github.com/users/rockymeza","html_url":"https://github.com/rockymeza","followers_url":"https://api.github.com/users/rockymeza/followers","following_url":"https://api.github.com/users/rockymeza/following{/other_user}","gists_url":"https://api.github.com/users/rockymeza/gists{/gist_id}","starred_url":"https://api.github.com/users/rockymeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rockymeza/subscriptions","organizations_url":"https://api.github.com/users/rockymeza/orgs","repos_url":"https://api.github.com/users/rockymeza/repos","events_url":"https://api.github.com/users/rockymeza/events{/privacy}","received_events_url":"https://api.github.com/users/rockymeza/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2015-01-22T16:05:02Z","updated_at":"2016-08-31T21:51:09Z","closed_at":null,"body":"Hi,\r\n\r\nI ran into an issue when trying to use the r.js optmizer with almond. I would have liked to open a pull request, but I'm a little unsure of how where to start with it.\r\n\r\n## Problem\r\nI'm using relative imports from files that are using loader plugins. Here's what my set up is like:\r\n\r\n```javascript\r\n// main.js\r\nrequire(['jsx!components/Foo'], function(Foo) { // do stuff });\r\n\r\n// components/Foo\r\ndefine(['jsx!./Bar'], function(Bar) { // do stuff });\r\n\r\n// components/Bar\r\ndefine(/* doesn't matter */);\r\n```\r\n\r\nI get an error because it's trying to use `req.toUrl('jsx!jsx!components/Bar')`. `req.toUrl` isn't available obviously, but the module ID is also wrong.\r\n\r\n## Proposed Solution\r\nI found out that the module ID is being normalized incorrectly, so I modified [this line](https://github.com/jrburke/almond/blob/master/almond.js#L37) to look like the following and then the problem was solved.\r\n\r\n```javascript\r\nbaseParts = baseName && splitPrefix(baseName)[1].split(\"/\"),\r\n```\r\n\r\nI'm not sure what to do next though."},"comment":{"url":"https://api.github.com/repos/requirejs/almond/issues/comments/243913923","html_url":"https://github.com/requirejs/almond/issues/101#issuecomment-243913923","issue_url":"https://api.github.com/repos/requirejs/almond/issues/101","id":243913923,"user":{"login":"pieceOpiland","id":8548667,"avatar_url":"https://avatars.githubusercontent.com/u/8548667?v=3","gravatar_id":"","url":"https://api.github.com/users/pieceOpiland","html_url":"https://github.com/pieceOpiland","followers_url":"https://api.github.com/users/pieceOpiland/followers","following_url":"https://api.github.com/users/pieceOpiland/following{/other_user}","gists_url":"https://api.github.com/users/pieceOpiland/gists{/gist_id}","starred_url":"https://api.github.com/users/pieceOpiland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieceOpiland/subscriptions","organizations_url":"https://api.github.com/users/pieceOpiland/orgs","repos_url":"https://api.github.com/users/pieceOpiland/repos","events_url":"https://api.github.com/users/pieceOpiland/events{/privacy}","received_events_url":"https://api.github.com/users/pieceOpiland/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T21:51:09Z","updated_at":"2016-08-31T21:51:09Z","body":"I also seem to be running into this problem with the `require-cs` plugin. \r\n\r\nI've thrown together a jsfiddle containing the built output at: https://jsfiddle.net/bbwvf785/1/\r\n\r\nIt is unable to resolve the module `cs!./myModule`. When I substitute absolute paths in for the relative paths, the module is properly resolved. I believe it's because the module it's relative to also contains the plugin prefix. As a result, almond searches for `cs!cs!src/myModule` similarly to how it looks for `jsx!jsx!components/Bar` in the original comment.\r\n\r\nI tried adding \r\n```\r\nrelName = splitPrefix(relName)[1];\r\n```\r\nafter [line 208](https://github.com/requirejs/almond/blob/master/almond.js#L208) and it seems to have resolved the issue in my scenario.\r\n\r\nIf I can provide any more information, please let me know."}}
{"actor":{"display_login":"pieceOpiland"}}