You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been maintaining universal-react-scripts, a version of react-scripts which includes SSR support. I've recently been trying to merge in the changes from 3.3.0, but as it stands, it would now require that instead of just asking the user to specify --scripts-version with CRA, they'll also need to specify the --template option.
The reason for this change is that universal-react-scripts was already applying some changes to the template within its init script, with the files stored next to the existing template directories. However, with 3.3.0, the template could be anything -- so it's no longer possible to apply this transformation. Instead, the user will need to specify an SSR template from the start.
Describe the solution you'd like
For something like SSR, the template and scripts version need to work together. To facilitate this, I propose that we add support for a defaultScriptsVersion property to template.json. Then, the create-react-app script should:
Install and unpack the template to get access to template.json.
Check for a defaultScriptsVersion, falling back to react-scripts as the default.
Then install the scripts and other packages as before.
Describe alternatives you've considered
The obvious alternative is to ask people to pass compatible --scripts-version and --template options to create-react-app:
This is pretty verbose though, and will break if only one of the two options are passed. Ideally, the user could just do this:
npx create-react-app --template=universal
Another alternative would be to somehow allow the scripts version to transform the template name. This has the advantage of allowing the scripts to bail on unsupported templates -- but it sounds far more complicated.
The text was updated successfully, but these errors were encountered:
jamesknelson
changed the title
Support for setting deafult scripts-version from template.json
Support for setting default scripts-version from template.json
Jan 18, 2020
Is your proposal related to a problem?
I've been maintaining universal-react-scripts, a version of react-scripts which includes SSR support. I've recently been trying to merge in the changes from 3.3.0, but as it stands, it would now require that instead of just asking the user to specify
--scripts-version
with CRA, they'll also need to specify the--template
option.The reason for this change is that universal-react-scripts was already applying some changes to the template within its
init
script, with the files stored next to the existingtemplate
directories. However, with 3.3.0, the template could be anything -- so it's no longer possible to apply this transformation. Instead, the user will need to specify an SSR template from the start.Describe the solution you'd like
For something like SSR, the template and scripts version need to work together. To facilitate this, I propose that we add support for a
defaultScriptsVersion
property totemplate.json
. Then, thecreate-react-app
script should:template.json
.react-scripts
as the default.Describe alternatives you've considered
The obvious alternative is to ask people to pass compatible
--scripts-version
and--template
options tocreate-react-app
:This is pretty verbose though, and will break if only one of the two options are passed. Ideally, the user could just do this:
Another alternative would be to somehow allow the scripts version to transform the template name. This has the advantage of allowing the scripts to bail on unsupported templates -- but it sounds far more complicated.
The text was updated successfully, but these errors were encountered: