{"action":"created","issue":{"url":"https://api.github.com/repos/anodynos/uRequire/issues/65","labels_url":"https://api.github.com/repos/anodynos/uRequire/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/anodynos/uRequire/issues/65/comments","events_url":"https://api.github.com/repos/anodynos/uRequire/issues/65/events","html_url":"https://github.com/anodynos/uRequire/issues/65","id":75316859,"number":65,"title":"Linear dependencies between imported modules become circular","user":{"login":"Demurgos","id":2262218,"avatar_url":"https://avatars.githubusercontent.com/u/2262218?v=3","gravatar_id":"","url":"https://api.github.com/users/Demurgos","html_url":"https://github.com/Demurgos","followers_url":"https://api.github.com/users/Demurgos/followers","following_url":"https://api.github.com/users/Demurgos/following{/other_user}","gists_url":"https://api.github.com/users/Demurgos/gists{/gist_id}","starred_url":"https://api.github.com/users/Demurgos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Demurgos/subscriptions","organizations_url":"https://api.github.com/users/Demurgos/orgs","repos_url":"https://api.github.com/users/Demurgos/repos","events_url":"https://api.github.com/users/Demurgos/events{/privacy}","received_events_url":"https://api.github.com/users/Demurgos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-11T18:33:48Z","updated_at":"2015-07-12T09:20:28Z","closed_at":null,"body":"Hi,\r\nFirst of all I would really thank you for this module: if I could star it 10 times, I would! It really saved me a lot of troubles when exporting some common components for node and the client.\r\n\r\nI really like the possibility to import general purpose modules (Q, _, custom helpers, etc.) but I feel that I encountered an issue.\r\nI wrote two modules `helper.js` & `_Error.js`.\r\nThe first one provides some general purpose functions independent of the platform, ie. I included an `inherits` function (similar to the one in Node's `util`) so I can use it in the browser too.\r\nThe second one extends the native `Error` to provide more constructors, add data to follow error causes easily in JS, provide easier error naming & output all these data nicely.\r\n\r\nNote that `_Error` extends the native `Error` with `helper.inherits(_Error, Error)` so it stays compatible with the test `_error instanceof Error`. **`_Error` requires `helper`**.\r\n\r\nI expect to use these general purpose modules in my whole application so I would like to add both of these modules in my config:\r\n\r\n\turequire: {\r\n\t\t_defaults: {\r\n\t\t\tbundle: {\r\n\t\t\t\t// ...\r\n\t\t\t\tdependencies: {\r\n\t\t\t\t\timports: {\r\n\t\t\t\t\t\t\"cmn/js/core/helper\": \"helper\",\r\n\t\t\t\t\t\t\"cmn/js/core/_Error\": \"_Error\"\r\n\t\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\nThe problem is that now, `helper` is required in `_Error` (that's what I need) but `_Error` is also required in `helper` (I don't really need that there, if there's really a problem I'll just use the native `Error`).\r\n**Because both of these modules are imported, their \"linear\" relation is lost and I get circular dependencies.** I cannot really force the order of the imports (I tried: `_Error` is evaluated before `helper`, bad luck...) even if I try to explicitly add `require(\"./helper\")` in `_Error` to enforce their relation.\r\n\r\nIn this example, as in many other situations I guess, I could simply copy the code required during the creation of the object to avoid any relation between my modules but I feel there must be a better option.\r\nIn this example, I use just  `helper.inherits` during the evaluation of `_Error`, but if I think that dependencies between general purpose modules and libraries like `Q` or `_` should work automagically like the rest of this module.\r\n\r\nI would like to thank you again for this fantastic module and hope that this example can help to improve it. ;)"},"comment":{"url":"https://api.github.com/repos/anodynos/uRequire/issues/comments/120703039","html_url":"https://github.com/anodynos/uRequire/issues/65#issuecomment-120703039","issue_url":"https://api.github.com/repos/anodynos/uRequire/issues/65","id":120703039,"user":{"login":"Demurgos","id":2262218,"avatar_url":"https://avatars.githubusercontent.com/u/2262218?v=3","gravatar_id":"","url":"https://api.github.com/users/Demurgos","html_url":"https://github.com/Demurgos","followers_url":"https://api.github.com/users/Demurgos/followers","following_url":"https://api.github.com/users/Demurgos/following{/other_user}","gists_url":"https://api.github.com/users/Demurgos/gists{/gist_id}","starred_url":"https://api.github.com/users/Demurgos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Demurgos/subscriptions","organizations_url":"https://api.github.com/users/Demurgos/orgs","repos_url":"https://api.github.com/users/Demurgos/repos","events_url":"https://api.github.com/users/Demurgos/events{/privacy}","received_events_url":"https://api.github.com/users/Demurgos/received_events","type":"User","site_admin":false},"created_at":"2015-07-12T09:20:27Z","updated_at":"2015-07-12T09:20:27Z","body":"Sorry, I was unavailable for few weeks and then it took me some time to gather the different files to set up the repo.\r\n\r\nSo,  in my case I \"**DONT want to have circular dependency**\" so I wrote a resource-converter (it's the first time I tried, it's great !)\r\nI did not really understand how to use \"booleanOrFilespecs\" but its purpose seems to provide a clean way to whitelist/blacklist imports, right ?\r\n\r\nSo, here is the repository which highlights my structure and my problem:\r\nhttps://github.com/Demurgos/urequire-imports-dependencies\r\n\r\nI also thought that a solution could be to enforce explicit `require` for these kind of modules (because they are rare) but it might break some retro-compatibility and would require more work."}}