question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: `run` and `watch` scripts to use different entry points

See original GitHub issue

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 and react-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 script src/populate.js to populate initial data in a remote backend. You could add to your npm scripts:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "eject": "react-scripts eject",
    "populate": "react-scripts run src/populate.js"
  },

and then when you ran npm run populate it would invoke src/populate.js but do all the babel preprocessing to let you use ES6 features. watch would work just like run, but when any file changed it would restart the process. So watch would be used for long-running processes; run would be used for one-off scripts. run here works similarly to rails 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?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
tslatercommented, Sep 30, 2016

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.

2reactions
lackercommented, Jul 26, 2016

OK I am going to take a stab at creating run, and then depending on how that goes maybe watch will also be useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposal: add tasks to the config file #12764 - denoland/deno
Context Currently, there is no way to express "entry" points to an Deno application as well as provide a way of lightweight task ......
Read more >
5 Easy Script Templates – Promotional Video (+ Examples)
Below are the five easy promotional video script templates that you can use to get started and examples to inspire you. Remember your...
Read more >
Cold Calling Scripts: 25 Script Examples & Call Tips | Pipedrive
New to cold calling or want to improve? Use these 25 expert-generated cold calling scripts to ace the cold calling definition of success....
Read more >
How to Write a Video Script [Template + Video] - HubSpot Blog
Start writing your script, section by section. Edit your video script. Do a verbal run-through off-camera. 1. Choose your target audience.
Read more >
Entry Points - webpack
Single Entry Syntax is a great choice when you are looking to quickly set up a webpack configuration for an application or tool...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found