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.

A global CLI for running a single component

See original GitHub issue

This is something @lacker was working on before Create React App. That project got shelved but I think we could revive it in some form now.

The idea is that instead of creating a project, you just start with a single file that is the root component:

App.js

import React from 'react';

export default function App() {
  return <h1>Hello</h1>;
}
run-react-component App.js

It would use the same infrastructure as Create React App (exact same Babel and Webpack settings and CLI output), but would work in any folder without npm start.

So you could run-react-component NavBar.js and see just that component, regardless of where it is in the project, and whether it is in a project or not. The only run-react-component requirement is that whatever you import (e.g. react) exists in node_modules.

Benefits of this approach:

  • Can jump right into prototyping with a single file. (#642)
  • The install cost is only paid once, you can run run-react-component right away in any folder on the disk. (The downside is you actually have to update global CLI to get updates.)
  • We could offer a way to “convert” such a prototype into a full CRA-based project, and they will be compatible.
  • You could even use that in a CRA-based project to work on a single component at a time.

What do you think? Would that be useful?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:69
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

8reactions
andreypoppcommented, Sep 14, 2016

Do we really need another project for that? Maybe it is better to rename CRA to react-cli and make it host both CRA functionality and proposed run-react-component?

  • react create-app
  • react run-component
3reactions
gaearoncommented, Sep 30, 2016

I think documenting Storybook integration might address this better than us building a dedicated tool. Closing in favor of #738.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng generate component using the CLI - Pluralsight
ng generate component is a simple one-line command which creates different files and a folder, and it references the newly created component ......
Read more >
How to run a single .spec.ts file in an angular-cli project?
I can temporarily modify tests.ts to only load a single .spec.ts file, but this seems very hacky. There doesn't appear to be an...
Read more >
How to Build a Command Line (CLI) Tool in NodeJS
in our project. This command creates a symbolic link between the project directory and executable command.
Read more >
CLI Overview and Command Reference - Angular
The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command...
Read more >
Angular CLI Behind the Scenes - Part One
As of today, the preferred solution to this problem is a command-line application generator (rather than, say, a GUI wizard-based approach) called the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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