Move more things to react-dev-utils
Created by: ForbesLindesay
I want to make react-scripts easier to fork/extend. I think the way to do that is to move as much as possible into react-dev-utils so that react-scripts can be a smaller package that changes less frequently. Then you can always just update the react-dev-utils to get most new features in react-scripts.
This should also make ejecting much less painful, as ejected projects still depend on react-dev-utils
My proposal is to move:
- config/webpackDevServer.config.js - This can just take
publicPathandappPublicas additional options - config/polyfills.js - this can just be moved as is - do we want to include it in what gets ejected still, or just reference it from react-dev-utils? I feel like just referencing it probably makes the most sense.
- config/env.js - This will need to take
dotenvPathas an argument, anddelete require.cache[require.resolve('./paths')];will have to be done elsewhere. - each of the three jest transforms - these can just be moved as is, and then they won't need to be ejected either.
- scripts/utils/createJestConfig.js - this will just need to take
paths.testsSetupandpaths.appPackageJsonas arguments.
I then think we should add a pathUtils module in react-dev-utils, containing resolveApp, getPublicUrl, getServedPath and resolveOwn. This should simplify config/paths.js quite a bit.
At this point, I think we should re-evaluate what else needs moving. If nobody objects, I'll start submitting pull requests for these changes.