A global CLI for running a single component
See original GitHub issueThis 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:
- Created 7 years ago
- Reactions:69
- Comments:24 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 proposedrun-react-component
?react create-app
react run-component
I think documenting Storybook integration might address this better than us building a dedicated tool. Closing in favor of #738.