-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: run
and watch
scripts to use different entry points
#218
Comments
The way people normally do this is to drop a Note BTW that if #189 gets merged – it can't be literally the same Babel config, since Node doesn't natively support ES modules. |
Yeah, I would normally use |
@ForbesLindesay also suggested this in another thread. Seems like a useful feature. |
I'm not sure I understand the use case for watch though, can you elaborate? |
There's something a little weird about having a |
@gaearon @taion Well build-related tasks are certainly one use case. You might run a script to update something that you've vendored, for example. If it's straightforward to add your own build-related scripts, then it will let people add features to their projects without needing support from the build tooling provided by My hope is, the more there are generic tools to let developers use the runtime environment that |
@lacker "Provision a dev instance in Firebase" is a good point. I bring up "build tasks" as something this isn't necessarily a good fit for, because ideally you'd want to also run build tasks when you do |
An example where I would want |
OK I am going to take a stab at creating |
What is the plan for dealing with ES modules? I don't necessarily see a way around it without creating a separate Babel config for this feature that keeps transpiling to CommonJS (which doesn't seem like a good idea), or bundling with Webpack instead of using babel-node. |
I think it would make more sense to use webpack than babel-node, because then you'll be able to rely on the same loaders and plugins you're already using in the application code. It might be confusing for a user if they can't load some filetypes in some of their JS, but they can elsewhere. |
Agree. |
I implemented the |
Closing for now as doesn’t seem to catch on. |
We're using a mono-repo and link local dependencies within the same repo for fast development. It's sometimes helpful to run watch on dependent module and develop on it while running it as a dependency. I think this would be a nice feature to have. |
As I start to build out real apps I find cases where I want to run a one-off script using the same language features as the rest of my app. If the only way to enter my code is via
npm start
then there's no way to do this.The proposed solution is to add two more scripts,
react-scripts run
andreact-scripts watch
that the developer can use to make their own npm script which uses the same babel environment. For example, let's say you had a scriptsrc/populate.js
to populate initial data in a remote backend. You could add to your npm scripts:and then when you ran
npm run populate
it would invokesrc/populate.js
but do all the babel preprocessing to let you use ES6 features.watch
would work just likerun
, but when any file changed it would restart the process. Sowatch
would be used for long-running processes;run
would be used for one-off scripts.run
here works similarly torails run
if you are familiar with rails.Without this sort of feature, developers are likely to make these one-off scripts using ES5 or using whatever language subset is node-compatible. This would also be a useful hook for people who wanted to build node server functionality, while not forcing it on anyone.
What do you think?
The text was updated successfully, but these errors were encountered: