{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/10966","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/10966/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/10966/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/10966/events","html_url":"https://github.com/facebook/react-native/issues/10966","id":189613897,"number":10966,"title":"Official, gradual path to RN packages not publishing untranspiled code","user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-16T07:17:22Z","updated_at":"2016-11-21T06:29:59Z","closed_at":null,"body":"The current practice in the RN community for package authors is to publish untranspiled code, to npmignore babelrc, and for the RNP to transpile `node_modules`.\r\n\r\nWhile this may work great for the RN community, this defies many best practices in the wider node/npm/JS community:\r\n - package.json's \"main\" only points to ES5 commonJS\r\n - `npm explore foo && npm install && npm test` should work (note this isn't universal, but it's frustrating to be asked to npmignore `.babelrc` and break this use case due to the RNP)\r\n\r\nIn addition, this practice kind of permanently cements RN packages with the transpiler settings that the RNP uses - which, since it includes not-yet-stage-4 features, are quite likely to change in a breaking way in the future.\r\n\r\nHere's my proposal to enable the benefits of the current approach (cleaner stack traces, optimization opportunities within the RNP, etc) in a way that will allow RN packages to rejoin the wider JS ecosystem:\r\n\r\n 1. Designate a new top-level `package.json` key - let's go with \"sources\" for the time being. This contains an object. All subkeys of \"sources\" are optional.\r\n 1. Within \"sources\":\r\n   1. \"raw\" points to the entry point for utterly untranspiled code. `.babelrc` (or other babel config locations), if provided, configure how this code should be transformed.\r\n   1. \"react-native-v1\" (swap out v1 for any versioning scheme; this frees up the RNP to change their preferred transpiler settings freely.\r\n   1. \"node4\", \"node5\", \"node6\", \"node7\", etc: code transpiled down to features matching the indicated major node version, following https://www.npmjs.com/package/babel-preset-node7, https://www.npmjs.com/package/babel-preset-node6, etc.\r\n   1. \"es2015\", \"es2016\", etc: code transpiled down to features that are included in the given year of publication of the ecmascript standard.\r\n 1. The RNP ships with support for this, with priority: [\"react-native-*\", \"node-*\" (>= the major node version, obv), \"main\" (with transpiling)]. This change is loudly communicated with blogs, tweets, and documentation.\r\n 1. At some future point (this can be as soon, or as indefinite, as is deemed necessary), the RNP will cease transpiling \"main\" - since the other \"sources\" don't require looking for babel configs, this will be when RN packages can (and should) publish their `.babelrc`s again.\r\n\r\nThis approach allows for supporting other languages, future transpiler settings, etc, in a nonbreaking way, without infecting the npm ecosystem with untranspiled \"main\" entry points (inhibiting people's ability to share RN packages across normal react). A package will always be able to choose to omit \"main\" entirely, which will clearly and explicitly convey to users that their package must not be used without the RNP.\r\n\r\nFurther reading (credit @ide): https://gist.github.com/ide/e7b9181984933ebb0755c7367a32e7e8"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/261854872","html_url":"https://github.com/facebook/react-native/issues/10966#issuecomment-261854872","issue_url":"https://api.github.com/repos/facebook/react-native/issues/10966","id":261854872,"user":{"login":"skevy","id":131916,"avatar_url":"https://avatars.githubusercontent.com/u/131916?v=3","gravatar_id":"","url":"https://api.github.com/users/skevy","html_url":"https://github.com/skevy","followers_url":"https://api.github.com/users/skevy/followers","following_url":"https://api.github.com/users/skevy/following{/other_user}","gists_url":"https://api.github.com/users/skevy/gists{/gist_id}","starred_url":"https://api.github.com/users/skevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skevy/subscriptions","organizations_url":"https://api.github.com/users/skevy/orgs","repos_url":"https://api.github.com/users/skevy/repos","events_url":"https://api.github.com/users/skevy/events{/privacy}","received_events_url":"https://api.github.com/users/skevy/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T06:29:59Z","updated_at":"2016-11-21T06:29:59Z","body":"Somewhat related -- I just made this: https://github.com/skevy/babel-preset-react-native-syntax\r\n\r\nThis preset would help React Native package authors transpile their code down to what is described here as \"sources.react-native-v1\"."}}
{"actor":{"display_login":"skevy"}}