{"action":"created","issue":{"url":"https://api.github.com/repos/less/less.js/issues/2618","labels_url":"https://api.github.com/repos/less/less.js/issues/2618/labels{/name}","comments_url":"https://api.github.com/repos/less/less.js/issues/2618/comments","events_url":"https://api.github.com/repos/less/less.js/issues/2618/events","html_url":"https://github.com/less/less.js/issues/2618","id":90029327,"number":2618,"title":"New import option `node` to use require.resolve logic","user":{"login":"JedWatson","id":872310,"avatar_url":"https://avatars.githubusercontent.com/u/872310?v=3","gravatar_id":"","url":"https://api.github.com/users/JedWatson","html_url":"https://github.com/JedWatson","followers_url":"https://api.github.com/users/JedWatson/followers","following_url":"https://api.github.com/users/JedWatson/following{/other_user}","gists_url":"https://api.github.com/users/JedWatson/gists{/gist_id}","starred_url":"https://api.github.com/users/JedWatson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JedWatson/subscriptions","organizations_url":"https://api.github.com/users/JedWatson/orgs","repos_url":"https://api.github.com/users/JedWatson/repos","events_url":"https://api.github.com/users/JedWatson/events{/privacy}","received_events_url":"https://api.github.com/users/JedWatson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-06-22T07:07:43Z","updated_at":"2015-06-24T12:03:17Z","closed_at":null,"body":"This is a spin-off from the conversation in #2560.\r\n\r\nAs we start publishing more front-end components on npm (in my case specifically, react.js components) less would provide a _great_ way to bundle customisable CSS alongside the javascript code, that can be provided as a built file, or as a less file supporting variables for themeing, etc.\r\n\r\nHowever there's a critical problem in doing so, because it's impossible to know where the actual path of the module is without replicating node's `require.resolve` logic, or using the [npm-import plugin](https://github.com/less/less-plugin-npm-import).\r\n\r\nFor clarity; if I depend on `react-select` in `keystone` with a require path like `../../node_modules/react-select/less/component.less`, it works _until_ the project that depends on `keystone` *also* depends on `react-select`, at which point the path becomes `../../../node_modules/react-select/less/component.less` and my import statement breaks.\r\n\r\nYou can see [my workaround here](https://github.com/keystonejs/keystone/blob/master/admin/app/static.js#L31-L41).\r\n\r\nI propose a new [import option](http://lesscss.org/features/#import-options), `node`, that would work like this:\r\n\r\n```css\r\n@import (node) \"react-select/less/component.less\";\r\n```\r\n\r\nThe node option would use the `require.resolve` function in node.js / io.js to get the path to the `react-select` module, then prepend that to the rest of the specified path. In my case above, it would be expanded to the equivalent of:\r\n\r\n```\r\n@import \"../../node_modules/react-select/less/component.less\";\r\n```\r\n\r\nFor context, we're working on a React.js UI Component Library called [Elemental UI](http://elemental-ui.com) which is composed of discrete, independently packaged UI components (e.g [react-date-select](https://github.com/JedWatson/react-date-select)), and using that in [KeystoneJS](http://keystonejs.com) at which point things get _really crazy_ without this feature.\r\n\r\nFor the moment the `npm-import` LESS plugin is a workaround, as is the logic I've written into Keystone, but this would really be much clearer as a language feature and I'm not particularly comfortable enforcing that plugin on our audience; I believe plugins should be included at the discretion of a project author, not because some package (potentially several packages deep) in the dependency graph requires them."},"comment":{"url":"https://api.github.com/repos/less/less.js/issues/comments/114844623","html_url":"https://github.com/less/less.js/issues/2618#issuecomment-114844623","issue_url":"https://api.github.com/repos/less/less.js/issues/2618","id":114844623,"user":{"login":"seven-phases-max","id":5304376,"avatar_url":"https://avatars.githubusercontent.com/u/5304376?v=3","gravatar_id":"","url":"https://api.github.com/users/seven-phases-max","html_url":"https://github.com/seven-phases-max","followers_url":"https://api.github.com/users/seven-phases-max/followers","following_url":"https://api.github.com/users/seven-phases-max/following{/other_user}","gists_url":"https://api.github.com/users/seven-phases-max/gists{/gist_id}","starred_url":"https://api.github.com/users/seven-phases-max/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seven-phases-max/subscriptions","organizations_url":"https://api.github.com/users/seven-phases-max/orgs","repos_url":"https://api.github.com/users/seven-phases-max/repos","events_url":"https://api.github.com/users/seven-phases-max/events{/privacy}","received_events_url":"https://api.github.com/users/seven-phases-max/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T12:03:17Z","updated_at":"2015-06-24T12:03:17Z","body":"@dcousens\r\n\r\n>However, I don't think just \"sitting back\" and waiting 6-12 months is the right solution either\r\n\r\nYour misassumption is that you think there's a choice between \"waiting 6-12 months\" and \"something else\". Well, look at [the query](https://github.com/less/less.js/issues?q=is%3Aopen+is%3Aissue+label%3AReadyForImplementation) to get the idea of why it's wrong.\r\n\r\n<sub>\r\nSo... Not happy with plugins? This is sad, but this is only thing we can offer for now. So it's primarily *your* interest to help to make the plugin subsystem improved and wide-spread. Otherwise (*half-joking mode on*:) it's not a big deal to put \"ReadyForImplementation\" label for this FR and get it buried with other FRs within the query I linked above. \r\n(And it's not even about asking you or @JedWatson to make an initial PR, count how often I used \"maintain\" and \"support\" words in my previous post for another hint).\r\n\r\n>you'll come into a situation where some people will move away\r\n\r\nYep, yet another common convincing argument and yet another common misassumtion that any of active Less contributors get some direct benefits from the number of Less users...\r\n</sub>"}}