{"action":"created","issue":{"url":"https://api.github.com/repos/sass/node-sass/issues/894","labels_url":"https://api.github.com/repos/sass/node-sass/issues/894/labels{/name}","comments_url":"https://api.github.com/repos/sass/node-sass/issues/894/comments","events_url":"https://api.github.com/repos/sass/node-sass/issues/894/events","html_url":"https://github.com/sass/node-sass/issues/894","id":71015982,"number":894,"title":"The last `.contents` property returned by an importer is always used","user":{"login":"jameslnewell","id":2237996,"avatar_url":"https://avatars.githubusercontent.com/u/2237996?v=3","gravatar_id":"","url":"https://api.github.com/users/jameslnewell","html_url":"https://github.com/jameslnewell","followers_url":"https://api.github.com/users/jameslnewell/followers","following_url":"https://api.github.com/users/jameslnewell/following{/other_user}","gists_url":"https://api.github.com/users/jameslnewell/gists{/gist_id}","starred_url":"https://api.github.com/users/jameslnewell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameslnewell/subscriptions","organizations_url":"https://api.github.com/users/jameslnewell/orgs","repos_url":"https://api.github.com/users/jameslnewell/repos","events_url":"https://api.github.com/users/jameslnewell/events{/privacy}","received_events_url":"https://api.github.com/users/jameslnewell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sass/node-sass/labels/Invalid%20-%20By%20Design","name":"Invalid - By Design","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-04-26T05:54:49Z","updated_at":"2015-09-21T09:39:41Z","closed_at":"2015-09-21T07:50:46Z","body":"When an importer function returns the `.contents` string, node-sass always uses the last returned value is used.\r\n\r\nThe following example imports a file called `foobar` twice with a different `.contents` returned each time. Node-sass always uses the last `.contents` for both imports resulting in `.barfoo` being repeated twice.\r\n\r\n    var sass = require('node-sass');\r\n    \r\n    var i = 0;\r\n    \r\n    sass.render(\r\n      {\r\n        data: '@import \"foobar\"; @import \"foobar\";',\r\n        importer: function(file, prev, cb) {\r\n          console.log(file, prev);\r\n    \r\n          if (i++ === 0) {\r\n            cb({contents: '.foobar {color: red;}'});\r\n          } else {\r\n            cb({contents: '.barfoo {color: blue;}'});\r\n          }\r\n    \r\n        }\r\n      },\r\n      function(err, result) {\r\n        if (err) {\r\n          console.log(err);\r\n        } else {\r\n          console.log(result.css.toString());\r\n        }\r\n      }\r\n    );\r\n\r\nNote: Using a `.file` result for one import and a `.contents` result for the other import does not result in the same issue.\r\n\r\nI'm using node-sass `3.0.0-beta.7`, libsass `3.2.0-beta.6` and running on OS X 10.10.3."},"comment":{"url":"https://api.github.com/repos/sass/node-sass/issues/comments/141925393","html_url":"https://github.com/sass/node-sass/issues/894#issuecomment-141925393","issue_url":"https://api.github.com/repos/sass/node-sass/issues/894","id":141925393,"user":{"login":"saper","id":248374,"avatar_url":"https://avatars.githubusercontent.com/u/248374?v=3","gravatar_id":"","url":"https://api.github.com/users/saper","html_url":"https://github.com/saper","followers_url":"https://api.github.com/users/saper/followers","following_url":"https://api.github.com/users/saper/following{/other_user}","gists_url":"https://api.github.com/users/saper/gists{/gist_id}","starred_url":"https://api.github.com/users/saper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saper/subscriptions","organizations_url":"https://api.github.com/users/saper/orgs","repos_url":"https://api.github.com/users/saper/repos","events_url":"https://api.github.com/users/saper/events{/privacy}","received_events_url":"https://api.github.com/users/saper/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T09:39:41Z","updated_at":"2015-09-21T09:39:41Z","body":"Ruby has two methods (http://sass-lang.com/documentation/Sass/Importers/Base.html):\r\n\r\n````\r\n(Sass::Engine?) find(uri, options) \r\n(Sass::Engine?) find_relative(uri, base, options) \r\n````\r\n\r\nso there is some notion of the importer being relative to some abstract `base` (maybe a directory, maybe not), so different meanings of `uri` can be provided, per \"parent\" context. \r\n\r\n`prev` is I think just a simple workaround in libsass to provide something similar.\r\n\r\nPlus Sass importers may use http://sass-lang.com/documentation/file.SASS_REFERENCE.html#options to generate their output, but that does not necessary preclude idempotency (as long as the options stay constant per run). But this is another story (I think there is an issue for that somewhere)."}}