Created by: XerxesNoble
The pull request is motivated by: https://github.com/facebookincubator/create-react-app/issues/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.json
through the new property transpileDependencies
.
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.js
as 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-app
cd my-app
npm install @my-org/some-es6-module
-
npm start
/npm run build
- *Verify the source code was transpiled.