{"action":"created","issue":{"url":"https://api.github.com/repos/stylus/stylus/issues/1919","labels_url":"https://api.github.com/repos/stylus/stylus/issues/1919/labels{/name}","comments_url":"https://api.github.com/repos/stylus/stylus/issues/1919/comments","events_url":"https://api.github.com/repos/stylus/stylus/issues/1919/events","html_url":"https://github.com/stylus/stylus/issues/1919","id":77034394,"number":1919,"title":"Import resolution order causes unexpected problems","user":{"login":"kostko","id":543739,"avatar_url":"https://avatars.githubusercontent.com/u/543739?v=3","gravatar_id":"","url":"https://api.github.com/users/kostko","html_url":"https://github.com/kostko","followers_url":"https://api.github.com/users/kostko/followers","following_url":"https://api.github.com/users/kostko/following{/other_user}","gists_url":"https://api.github.com/users/kostko/gists{/gist_id}","starred_url":"https://api.github.com/users/kostko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kostko/subscriptions","organizations_url":"https://api.github.com/users/kostko/orgs","repos_url":"https://api.github.com/users/kostko/repos","events_url":"https://api.github.com/users/kostko/events{/privacy}","received_events_url":"https://api.github.com/users/kostko/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/stylus/stylus/labels/t:%20Bug","name":"t: Bug","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-16T13:06:38Z","updated_at":"2015-05-16T15:13:07Z","closed_at":null,"body":"It seems that files in the local directory can override imports from within plugins like `nib` which may cause unexpected import loops.\r\n\r\nTo reproduce, create a directory and install `stylus` and `nib`:\r\n```\r\n$ npm install stylus nib\r\n```\r\n\r\nIn the same directory, create a file called `text.styl` with the following contents:\r\n```stylus\r\n@import 'nib'\r\n```\r\n\r\nThen execute the following code via nodejs:\r\n```javascript\r\nvar stylus = require('stylus');\r\nvar nib = require('nib');\r\n\r\nstylus(\"@import 'text'\").use(nib()).render();\r\n```\r\n\r\nThe process will hang and start consuming CPU. It will only terminate after it runs out of stack space. There are two problems with the import process:\r\n* Files from the local directory can take precedence in imports within plugins. This means that local files can unexpectedly override things in the plugin just by having the same name as some styl file somewhere inside the plugin directory structure. When in the above example, the `nib` plugin does `@import 'text'`, the stylus compiler will import the local `text.styl` instead of having the one in the plugin take precedence.\r\n* Import loops are not detected and needlessly consume CPU.\r\n"},"comment":{"url":"https://api.github.com/repos/stylus/stylus/issues/comments/102635904","html_url":"https://github.com/stylus/stylus/issues/1919#issuecomment-102635904","issue_url":"https://api.github.com/repos/stylus/stylus/issues/1919","id":102635904,"user":{"login":"Panya","id":235637,"avatar_url":"https://avatars.githubusercontent.com/u/235637?v=3","gravatar_id":"","url":"https://api.github.com/users/Panya","html_url":"https://github.com/Panya","followers_url":"https://api.github.com/users/Panya/followers","following_url":"https://api.github.com/users/Panya/following{/other_user}","gists_url":"https://api.github.com/users/Panya/gists{/gist_id}","starred_url":"https://api.github.com/users/Panya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Panya/subscriptions","organizations_url":"https://api.github.com/users/Panya/orgs","repos_url":"https://api.github.com/users/Panya/repos","events_url":"https://api.github.com/users/Panya/events{/privacy}","received_events_url":"https://api.github.com/users/Panya/received_events","type":"User","site_admin":false},"created_at":"2015-05-16T15:13:07Z","updated_at":"2015-05-16T15:13:07Z","body":"I've added a proper check for import loops in the `dev` branch. Thanks for the report."}}