Skip to content
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

[Option] Disable automatic dependency installation #7568

Open
joebochill opened this issue Aug 19, 2019 · 4 comments
Open

[Option] Disable automatic dependency installation #7568

joebochill opened this issue Aug 19, 2019 · 4 comments

Comments

@joebochill
Copy link

Is your proposal related to a problem?

No

Describe the solution you'd like

It would be nice to be able to use create-react-app to create a new project without automatically installing all of the dependencies. Something like create-react-app app-name --skipInstall similar to how the @angular/cli works.

Describe alternatives you've considered

It doesn't appear that there are any options for configuring create-react-app other than additional logging. Manually creating a React project from scratch would be counterproductive.

Additional context

I find myself generating a lot of template/placeholder projects with create-react-app, without the need to run them right away. It would greatly speed up the process if I could optionally omit the dependency installation step.

@facultymatt
Copy link

facultymatt commented Sep 14, 2020

This would be a useful addition to CRA. In Storybooks, they support this option via the command line flag -s --skip-install so I would suggest using the same flag for this feature to bring consistency across the react ecosystem 😃

Here is the flag documented, which defaults to false.
https://github.com/storybookjs/storybook/blob/50367f9fa9ddb2fbec2177d7192ea88b62efe5e2/lib/cli/src/generate.ts#L21

Here is where they check and install deps based on this flag:
https://github.com/storybookjs/storybook/blob/f1a4722f513e567f1151aef33692a526823d24ed/lib/cli/src/initiate.ts#L70-L72

Looking at react-scripts, the line for installing deps is here:
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/scripts/init.js#L324-L331

I'd suggest wrapping that block in an additional check for skipInstall. I would avoid adding it to line 323 and that check is already a bit complex.

Here are the options where we'll need to add a -s --skip-install

Its not super clear to me how the options get passed to init, but I think its here:

run(
root,
appName,
version,
verbose,
originalDirectory,
template,
useYarn,
usePnp
);
??? Could use some direction here....

Lastly, I'm concerned there might be multiple places where dependencies are added, rather than just all at once at end of script, so we'd want to make sure we hit all of these places in our check, and that it didn't break functionality. Need to know which dependencies are installed to make "script" work versus. for the finished react-app.

@facultymatt
Copy link

Looking further here is the chain of functions from commander to init

@ckc1373
Copy link

ckc1373 commented Sep 17, 2020

I looked into this issue, and tried to implement the code discussed above for a PR. It seems like it would be very difficult to get working without a larger refactor. Adding a conditional check to the code at https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/scripts/init.js#L324-L331, only prevents the dependencies taken from whatever template is being used, which by default seems to be a very small portion of the packages installed.

You might also need to add some sort of conditional check here https://github.com/facebook/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L407. However, it seems like you need the installed packages here for the rest of the creation of a react app.

The code looks like it adds and installs packages along the way as it creates the new react app. In order to have an easy flag to stop installing dependencies, you may have to refactor it to not install along the way and instead install them all at the end, like other packages such as Docusaurus do. However, this seems like it would be difficult or impossible with this repository so this does not seem feasible to me.

@stevebeauge
Copy link

nearly two years later, is there any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants