Target specific node modules with babel. #3566
Target specific node modules with babel. #3566daxxsyntax wants to merge 2 commits intofacebook:masterfrom
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
I don't think that's the approach we want to take. I tried to describe how it should work in #1125 (comment). If you have any questions about it please don't hesitate to ask in #1125. I agree this is a very important feature but we need to get it right, and just running our Babel transforms over published code is not the right solution. |
|
FYI, we're starting the work to compile deps with Let us know if you have feedback about how this should work. |
The pull request is motivated by: #1125
From what I gathered from the thread, the only reason node_modules was not included in the babel transpile is because of performance, and the make perfect sense. However, app developers should at least be able to specify what modules they need transpiled.
Each module inside node_modules the applications requires to be transpiled can be specified in the applications
package.jsonthrough the new propertytranspileDependencies.Example
{ "name": "my-app", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.2.0", "react-dom": "^16.2.0", "react-scripts": "file:../packages/react-scripts/react-scripts-1.0.17.tgz", "@my-org/some-es6-module": "^0.0.1" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" }, "transpileDependencies": [ "@my-org/some-es6-module" ] }According to CONTRIBUTING.md this goes against the Core Ideas of the software, but I couldn't think of a better way (with my limited knowledge of this software) to implement this. Perhaps this will just serve as a concept.
Initially I wanted to make these changes to
packages/react-scripts/config/paths.jsas that is where most paths are kept, however, this is a dynamic list of paths, so I opted to add the code into each webpack config file.Test Plan
Not the most ideal, but I verified this change with the following steps
npm run create-react-app my-appcd my-appnpm install @my-org/some-es6-modulenpm start/npm run build