{"action":"created","issue":{"url":"https://api.github.com/repos/postcss/postcss-url/issues/43","labels_url":"https://api.github.com/repos/postcss/postcss-url/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/postcss/postcss-url/issues/43/comments","events_url":"https://api.github.com/repos/postcss/postcss-url/issues/43/events","html_url":"https://github.com/postcss/postcss-url/issues/43","id":101785786,"number":43,"title":"Switch to PostCSS Async API","user":{"login":"josh","id":137,"avatar_url":"https://avatars.githubusercontent.com/u/137?v=3","gravatar_id":"","url":"https://api.github.com/users/josh","html_url":"https://github.com/josh","followers_url":"https://api.github.com/users/josh/followers","following_url":"https://api.github.com/users/josh/following{/other_user}","gists_url":"https://api.github.com/users/josh/gists{/gist_id}","starred_url":"https://api.github.com/users/josh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josh/subscriptions","organizations_url":"https://api.github.com/users/josh/orgs","repos_url":"https://api.github.com/users/josh/repos","events_url":"https://api.github.com/users/josh/events{/privacy}","received_events_url":"https://api.github.com/users/josh/received_events","type":"User","site_admin":true},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-19T01:32:03Z","updated_at":"2015-08-24T21:18:18Z","closed_at":"2015-08-24T18:43:20Z","body":"According to the latest PostCSS plugin guidelines, plugins should [\"use asynchronous methods when it is possible\"](https://github.com/postcss/postcss/blob/master/docs/guidelines/plugin.md#22-use-asynchronous-methods-when-it-is-possible). Theres a number of places postcss-url makes blocking FS calls.\r\n\r\n* https://github.com/postcss/postcss-url/blob/130b43c9bc1e6f95d2aeb19ae8dcad26fa8f3693/index.js#L239\r\n* https://github.com/postcss/postcss-url/blob/130b43c9bc1e6f95d2aeb19ae8dcad26fa8f3693/index.js#L244\r\n* https://github.com/postcss/postcss-url/blob/130b43c9bc1e6f95d2aeb19ae8dcad26fa8f3693/index.js#L263\r\n* https://github.com/postcss/postcss-url/blob/130b43c9bc1e6f95d2aeb19ae8dcad26fa8f3693/index.js#L306\r\n* https://github.com/postcss/postcss-url/blob/130b43c9bc1e6f95d2aeb19ae8dcad26fa8f3693/index.js#L318\r\n* https://github.com/postcss/postcss-url/blob/130b43c9bc1e6f95d2aeb19ae8dcad26fa8f3693/index.js#L339\r\n\r\nIn order to clean this up, the postcss plugin API will need to return a Promise which will mark it as async forcing consumers to use `process(css).then(cb)`. This would probably be considered a major backwards incompatible change.\r\n\r\nBut I think it would be worth while to align to the plugin best practices as this plugin is listed under the official @postcss org.\r\n\r\nThere could be other benefits besides this cleanup. For one, I think it would be great to support async logic in the custom url function.\r\n\r\n``` js\r\n\"postcss-url\": {\r\n  url: function(url) {\r\n    return asyncCallToComputeAssetMD5(url).then(function(md5) {\r\n      return url + \"?\" + md5\r\n    })\r\n  }\r\n}\r\n```\r\n\r\nI'd be happy to help work on this. But I just wanted to get an idea if this would be a welcome direction.\r\n\r\nThanks!\r\n\r\n-\r\n\r\nCC: @MoOx @ai "},"comment":{"url":"https://api.github.com/repos/postcss/postcss-url/issues/comments/134383407","html_url":"https://github.com/postcss/postcss-url/issues/43#issuecomment-134383407","issue_url":"https://api.github.com/repos/postcss/postcss-url/issues/43","id":134383407,"user":{"login":"MoOx","id":157534,"avatar_url":"https://avatars.githubusercontent.com/u/157534?v=3","gravatar_id":"","url":"https://api.github.com/users/MoOx","html_url":"https://github.com/MoOx","followers_url":"https://api.github.com/users/MoOx/followers","following_url":"https://api.github.com/users/MoOx/following{/other_user}","gists_url":"https://api.github.com/users/MoOx/gists{/gist_id}","starred_url":"https://api.github.com/users/MoOx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MoOx/subscriptions","organizations_url":"https://api.github.com/users/MoOx/orgs","repos_url":"https://api.github.com/users/MoOx/repos","events_url":"https://api.github.com/users/MoOx/events{/privacy}","received_events_url":"https://api.github.com/users/MoOx/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T21:18:18Z","updated_at":"2015-08-24T21:18:18Z","body":"Feel free to let me know if you publish something so I can deprecated things over here."}}