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

Create-react-app overrides dependencies in my custom react-scripts template #2462

Closed
just-boris opened this issue Jun 3, 2017 · 6 comments
Closed

Comments

@just-boris
Copy link
Contributor

just-boris commented Jun 3, 2017

I am maintaining fork with a custom react-scripts package, which is based on Preact.
After the change, #1253 has been released the create-react-app command always installs the fixed set of packages do not use package.json from template folder anymore.

Sorry that I did not report it before because usually the update for global command create-react-app is not required and I had stuck at some old version. Recently I have got a report from users, just-boris#17 about that problem.
As a workaround, I have recommended installing preact manually, but it doesn't seem like a good solution.

Can I ask to change the behavior and pick up dependencies from project template folder instead of the hard-coded list with react and react-dom?

@gaearon
Copy link
Contributor

gaearon commented Jun 5, 2017

The issue is that reading it from package.json if only possible if that package.json is available immediately. However it's not (we fetch a fresh one).

Old versions used to run two installs: first for react-scripts and then for react and react-dom. But this is significantly slower than doing them all at the same time.

I’m open to suggestions for fixing this, but not at the expense of the install time for most users.

@ingoclaro
Copy link

ingoclaro commented Jun 6, 2017

could there be a postInstall hook (maybe read it from the template package.json)? In this case that script could uninstall/install the needed packages...

Other option is to run npm i again if using an external template.

@gaearon
Copy link
Contributor

gaearon commented Jun 22, 2017

I think that if you need it to install something other than React, you might as well use a forked global package (since technically it doesn’t “create React app” anymore). So I’ll close this, but I can take a PR that runs npm install in react-scripts/init.js if some deps are missing.

@gaearon gaearon closed this as completed Jun 22, 2017
@just-boris
Copy link
Contributor Author

Sure! So far I have got used to live with the fact, that I need to replace React->Preact manually.

@just-boris
Copy link
Contributor Author

An update here.

Some time before, CRA introduced newer react-error-overlay, that explicitly declares dependency from React. It means that preact-compat is not an optional, but must have. Currently, I am considering publishing fork of create-react-app package too, that will be installing the proper dependencies.

From the good news: error overlay works with Preact very well, giving me a better development experience without any issues along the way.

@Timer
Copy link
Contributor

Timer commented Oct 16, 2017

FYI: The next version of the overlay will be bundled and you will not need to worry about React compat.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants