npm @remix-run/cloudflare 1.4.0
v1.4.0

latest releases: 0.0.0-nightly-6eb6acf3f-20240511, 2.9.2, 2.9.2-pre.2...
2 years ago

In this release, we have decided on what we think is a better way to implement or to import our modules in your Remix projects. What exactly does this mean?

Upcoming changes to module imports

Today you can import all Remix modules from the remix package, whether they are server side or client side, node.js or cloudflare:

import { Link, json } from "remix";
  • Link is actually coming from @remix-run/react
  • json is coming from either @remix-run/node or @remix-run/cloudflare

We call these "magic imports" because they work with a bit of magic in the remix setup script.

In this release, we are encouraging you to update your imports to the actual packages that the modules come from with a migrate script that will do the work for you:

- import { Link, json } from "remix"
+ import { Link } from "@remix-run/react"
+ import { json } from "@remix-run/node"

What do I do next?

This release doesn't break your existing code. Your old imports are still supported. Because magic imports will eventually be deprecated, this release includes a migrate script to get your code updated beforehand. This script will:

  • update your imports to the proper packages
  • make any Remix-specific changes to your package.json
  • outline any manual work that might be needed on your part

To execute the script in your project:

  1. Upgrade @remix-run/dev to v1.4.0 (should be in your devDependencies)
  2. Run npx @remix-run/dev@latest migrate from your project root and follow the prompts

That's it, you're done!

Background

Because Remix runs in multiple platforms as well as in the browser, we thought it would make development easier to not have to worry about the server environment or browser when importing modules: everything could be imported from remix.

To make this work, the remix setup script copied the exports from @remix-run/react and @remix-run/{runtime} ( @remix-run/node, @remix-run/cloudflare, @remix-run/deno) to node_modules/remix. This way it didn't matter which environment you were deploying to, everything came from remix.

While this is nice when importing modules, it has a number of problems:

  • Various deploy targets use node_modules differently, and getting things to "just work" has created issues with deploying to those platforms
  • It breaks alternative package managers like pnpm and Yarn PnP
  • We're all running remix setup manually way more often than we'd like

Because of this, we'll soon be deprecating the "magic imports". This release does not deprecate them, it simply provides the migration script so you can move off of magic imports sooner than later.

What's Changed

✨ Features

  • @remix-run/dev: Introduce the migrate command to replace remix imports with specific @remix-run modules (#2670)

🐛 Bug fixes

  • Auto-detect package manager when installing via create-remix (#2562)
  • Fix Remix templates create-remix when the conflict with local files with the same name (#2733)

💅 Enhancements

  • Improvements to remix-serve to prevent crashing on various Node signals (#2528, #1822)
  • Make getDependenciesToBundle more resilient to misconfigured packages.json (#2593)

New Contributors

Full Changelog: v1.3.5...v1.4.0

Don't miss a new cloudflare release

NewReleases is sending notifications on new releases.