{"action":"created","issue":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/858","repository_url":"https://api.github.com/repos/gatsbyjs/gatsby","labels_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/858/labels{/name}","comments_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/858/comments","events_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/858/events","html_url":"https://github.com/gatsbyjs/gatsby/issues/858","id":224429345,"number":858,"title":"[1.0] Plugin packaging file structure","user":{"login":"0x80","id":1193520,"avatar_url":"https://avatars2.githubusercontent.com/u/1193520?v=3","gravatar_id":"","url":"https://api.github.com/users/0x80","html_url":"https://github.com/0x80","followers_url":"https://api.github.com/users/0x80/followers","following_url":"https://api.github.com/users/0x80/following{/other_user}","gists_url":"https://api.github.com/users/0x80/gists{/gist_id}","starred_url":"https://api.github.com/users/0x80/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0x80/subscriptions","organizations_url":"https://api.github.com/users/0x80/orgs","repos_url":"https://api.github.com/users/0x80/repos","events_url":"https://api.github.com/users/0x80/events{/privacy}","received_events_url":"https://api.github.com/users/0x80/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-04-26T11:05:13Z","updated_at":"2017-04-26T16:27:19Z","closed_at":null,"body":"Quoted from: https://github.com/gatsbyjs/gatsby/issues/324#issuecomment-297261038\r\n\r\n> On why no dist/lib folders — it's mainly because I don't want to have to rely on compiling the modules and not using a dist/lib folder means you have the option of writing straight uncompiled JS. I want to add support for sites to have a \"plugins\" folder where more complex sites can split up functionality into multiple plugins. We could add some sort of config in plugin's package.json to say where code is but the code for finding plugins is simpler by saying code is at the root of the plugin. I guess there's nothing preventing us from reading something out of a plugin's package.json which says where the code is at. We can't use the common convention of the index.js exporting the location of things because gatsby-node/gatsby-browser/gatsby-ssr code are all incompatible with each other given possible webpack/babel enhancements to the language.\r\n\r\nCurrently there are a lot of plugins which are defined in packages but don't follow normal package rules, where you have package.main pointing to the entry point, and exporting everything from there. I am trying to understand why the normal `package.main` wouldn't be sufficient. \r\n\r\nIf you want to create a plugin without compiling the source, wouldn't it be enough to point package.main to the source file and omit the build step?\r\n\r\nRegarding incompatibility between gatsby-node/gatsby-browser/gatsby-ssr, can't we give them their own babelrc config if they differ in how they should be compiled?\r\n\r\nIf in the future you want to support a plugins folder from client code directly, I think it wouldn't be hard to make a distinction from regular packages and just read a bunch of js files and treat them as plugins. I don't see your point about \"finding the sources\" if you use the standard package.main for it.\r\n\r\nTo me it feels dangerous to ignore normal npm package semantics, since I don't see a good reason. Right now I see a lot of index.js which are empty with a \"noop\" comment. Why are they not exporting the functions and components? \r\n\r\nI guess I might be missing the big picture, but I feel that every package could have\r\n\r\n* all its sources in `/src`\r\n* optionally compile to `/dist`\r\n* point package.main to the entry point\r\n* entry to export all functions and components.\r\n\r\nAlso the bin folders in the `gatsby` and `gatsby-dev-cli` packages should IMO just go into the `src` directory. Then their source can be simplified and cleaned up with babel. In the case of gatsby it can be compiled with a different babel preset to support node < 4\r\n\r\nI was trying to improve debugging (in VSCode debugger) by generating source maps. But those source maps ended up in the packages' root. This triggered my OCD and I started cleaning the structure and cli code 😅  I won't make a PR now because I wasn't expecting this discussion, but I can finish it maybe later when it is clear to me what the structure will be."},"comment":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/comments/297466523","html_url":"https://github.com/gatsbyjs/gatsby/issues/858#issuecomment-297466523","issue_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/858","id":297466523,"user":{"login":"KyleAMathews","id":71047,"avatar_url":"https://avatars0.githubusercontent.com/u/71047?v=3","gravatar_id":"","url":"https://api.github.com/users/KyleAMathews","html_url":"https://github.com/KyleAMathews","followers_url":"https://api.github.com/users/KyleAMathews/followers","following_url":"https://api.github.com/users/KyleAMathews/following{/other_user}","gists_url":"https://api.github.com/users/KyleAMathews/gists{/gist_id}","starred_url":"https://api.github.com/users/KyleAMathews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyleAMathews/subscriptions","organizations_url":"https://api.github.com/users/KyleAMathews/orgs","repos_url":"https://api.github.com/users/KyleAMathews/repos","events_url":"https://api.github.com/users/KyleAMathews/events{/privacy}","received_events_url":"https://api.github.com/users/KyleAMathews/received_events","type":"User","site_admin":false},"created_at":"2017-04-26T16:27:19Z","updated_at":"2017-04-26T16:27:19Z","body":">Regarding incompatibility between gatsby-node/gatsby-browser/gatsby-ssr, can't we give them their own babelrc config if they differ in how they should be compiled?\r\n\r\nIt's not babel it's webpack. Webpack allows you to require anything basically with its loaders which if you give that code to node.js, it chokes. SImilarly, many node.js packages can't be packaged for the web.\r\n\r\nSo we can't have an index.js that's blindly requiring everything because that'll break in node.\r\n\r\nSo either a) we have a convention that files are at the root of the plugin or b) we require config specifying a different root (e.g. dist) or c) people have to specify every plugin files location (though not by requiring).\r\n\r\nI like the idea of when compiling locally to only compile for whatever version of node the contributor is using. Right now it's set to node v4 as that's the minimum version of node we support https://github.com/gatsbyjs/gatsby/blob/1.0/.babelrc#L5\r\n\r\nOn search — I guess I don't have that problem since my searcher (silver searcher) is setup to ignore files listed in .gitignore... I'm sympathetic to this problem since I've run into it before and it's quite annoying."}}
{"actor":{"display_login":"KyleAMathews"}}