Created by: lacker
This adds a run
script so that you can invoke a script in the same ES6-and-React-compatible environment you get when you run npm start
, but in node.
To run a script:
- Put your script in
src
, like atsrc/foobar.js
react-scripts run foobar.js
I wanted to get feedback if this seems like it's headed in the right direction. In particular are these decisions the right behavior:
- This doesn't compile node_modules.
- This doesn't set NODE_ENV.
- This stores the compiled files in a global temp directory.
- This doesn't automatically polyfill
fetch
.
Things that I'm pretty sure are not the ideal behavior but can be improved later:
- This doesn't cache anything
- No sourcemaps
- No arguments are passed to the script
It seems like a lot of the behavior will be similar between "run a one-off script" and "run unit tests" so perhaps we should have some underlying library that is shared between this and testing like https://github.com/facebookincubator/create-react-app/pull/216 .