Redwood v0.27 🚀

Update: the latest release is v0.27.1. See this comment for details.

This release contains many important internal changes that improve security, TypeScript support, framework development CI/CD, and upgrades necessary to prepare for a future v1 release candidate (e.g. upgrading to React v17).

Thank you to all the amazing contributors who are keeping the PRs rolling! Redwood is amazing because of you :tada:

:warning: This release contains Breaking Changes and requires code modifications. See the “Breaking” and “How to Upgrade” sections for more information.

Changed

  • :information_source: Bump CRWA Node.js Engine requirement from 12 to 14 (#1946) 5dbb9e0 @thedavidprice
  • Replaces Flash with react-hot-toast (#1856) 4a899b5 ) @cannikin
  • Router Docs - Remove idea of sharing router outside of Redwood (#1900) 624b0d5 @andrew-hwahin
  • Port test-tutorial script to JS (#1896) df8d0c2 @dac09
  • :warning: Upgrade React to v17. (#1705) f586198 @peterp
  • :warning: Upgrade to Prisma v2.18.0 (skipping v2.17.0) (#1851) 9f62208 @thedavidprice
    • Contains changes that may be “Breaking” for some projects. See “Breaking” section below.
      • Release Notes: v2.17.0, v2.18.0
      • HIGHLIGHTS: Native Types are now stable, Prisma Migrate now works with cloud-hosted databases (requires additional config)
      • CHANGES: prisma db push flags have been changed, Relation syntax will no longer be updated automatically (use yarn redwood prisma format)

Added

Fixes


Breaking :warning:

Upgrading React and adding a package resolution

As of this version, Redwood is using React v17.0.1. However, other dependencies, e.g. Storybook, use a different version of React. This results in packages being duplicated and hoisted into web/node_modules, which breaks unexpected things.

Projects need to bump their version of React. Additionally, to avoid duplication and hoisting, the solution is to add a package resolution. See the “How to upgrade…” section below.

Bumping Node.js Engine to v14

Technically this is not (yet) a breaking change. We are bumping Redwood’s Node.js requirement to Node.js v14 (from v12) and strongly encourage you to make the change now in your project. See “How to upgrade…” section below.

Replace Flash with React Hot Toast [deprecation warning]

This release replaces our custom Flash stuff with react-hot-toast and updates the scaffold generators to generate with the new interface. Importing Flash will give a deprecation warning. Flash will be fully deprecated in Redwood v1 release.

Migration to react-hot-toast is not required yet unless you are using dismissMessage() and cycleMessage(), which will now be a noop and you’ll just see the deprecation notice.

See more information and a guide here for switching from Flash to Toaster.

Prisma Changes that may affect some projects

Prisma Type Mapping

Type mapping from Prisma schema to the database for Float has changed from Decimal to Double in MySQL and PostgreSQL. Check out this video guide, which covers how to upgrade and address the remapping of Float.

Breaking changes due to strict type diffing and native types

Prisma no longer allows the loose mapping of Prisma scalar types to database column types without the specific notation. For more info, see Prisma v2.17.0 Release Notes


How to upgrade to Redwood v0.27 from v0.26

:point_right: IMPORTANT: Skipping versions when upgrading is not recommended and will likely cause problems. Do read through all Release Notes between your current version and this latest version. Each minor release will likely require you to implement breaking change fixes and apply manual code modifications.

Manual Code Modifications

Step 1: React upgrade and resolutions

In your root package.json, add the following resolutions (see also this reference code):

+ "resolutions": {
+  "react-dom": "17.0.1",
+  "react": "17.0.1"
+  }

Depending on what Redwood version your project started on, there might be other lower priority changes to ./package.json. Now might be a good time to inspect the current create-redwood-app package.json template code here and make other updates if needed.

And in your web/package.json, make sure react and react-dom in your dependencies are at the correct version (see also this reference code):

-    "react-dom": "^16.13.1",
-    "react": "^16.13.1",
+    "react": "17.0.1",
+    "react-dom": "17.0.1",

Then run:

yarn install

:point_right: Note: When running yarn install during and after the upgrade you will see several warnings that are expected and safe to ignore:

[1/5] 🔍 Validating package.json... 
[2/5] 🔍 Resolving packages... 
warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3" 
warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3" 
warning Resolution field "react-dom@17.0.1" is incompatible with requested version "react-dom@^16.8.3" 
warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16.8.3" 
warning Resolution field "react-dom@17.0.1" is incompatible with requested version "react-dom@^16.8.3" 
warning Resolution field "react@17.0.1" is incompatible with requested version "react@^16"

Step 2: Running your app on Node.js v14.x

In your root package.json, make the following change (see also this reference code):

+ "engines": {
-  "node": ">=12”,
+  "node": ">=14",
+  }

Check if the file .nvmrc exists in your project root. If not, create it. Then add the following, which is a configuration option to use the lates LTS version of Node.js, which is currently v14.x. (see also this reference file):

lts/*

If you are deploying on Netlify or Vercel, the .nvmrc will automatically configure the build environment to use Node.js v14.x. There is an additional setting on Vercel you may change in Settings/General/“Node.js Version”. However, the .nvmrc file will take precedence.

Upgrade Packages

:point_right: IMPORTANT: In this version, upgrading packages is a two-step process. Please complete both steps to ensure you’ve resolved any possible issues with React package duplication.

Step 1

Run the following command within your App’s directory:

yarn rw upgrade

Step 2

Once the upgrade is complete, inspect the Web workspace for web/node_modules. If this directory is present (it most likely will be), remove it:

rm -rf web/node_modules

This command works for Mac and Linux. For Windows, use the applicable shell command to delete the directory and its contents.

Lastly, run a force install:

yarn --force

Confirm there are no duplicate react, react-dom, or core-js packages in web/node_modules (which might not exist at all). If you have questions about this process or need help, see this forum topic.

Need other help or having trouble upgrading packages? See this forum topic for manual upgrade instructions and general upgrade help.


Redwood Releases on GitHub

You can see all Redwood release notes and version history on GitHub

7 Likes

It looks like if you happen to be self-hosting, you’ll need to do one more thing:

Modify the .env.defaults file to include SAFE_GLOBAL_CONTEXT=1 - this is related to #1789.

Admin Edit: The error has been resolved in patch release v0.27.1. See this comment. We do not recommend setting this Env Var unless you fully understand the security implications.

@brentjanderson thank you for this. However, we do not advise setting that Env Var as this is not best practice for self-hosting. A couple questions:

  1. any chance you’re running local dev on Windows?
  2. any chance you could test your self-hosting environment, e.g. Container, to see if this is still an issue or if it possibly resolves?

GitHub Issue

For anyone else, experiencing this, please look at this GitHub Issue and continue the conversation here: After upgrade to 0.27: Context creation failed · Issue #1993 · redwoodjs/redwood · GitHub

This is a priority issue for us. We are actively looking into what’s going on to work on a patch.

Thanks all!

Patch Release v0.27.1

We have released v0.27.1, which fixes the GraphQL Context creation failed error.

How to upgrade

If you are currently on v0.27.0, upgrade by running:

yarn redwood upgrade

Revert Env Var (if applicable)

If you already attempted to resolve this error by adding SAFE_GLOBAL_CONTEXT=1, we strongly advise removing this Env Var unless you fully understand the security implications.

1 Like