Skip to content

v1.2.0

Compare
Choose a tag to compare
@chaance chaance released this 16 Feb 20:24
· 3764 commits to main since this release

We've been plugging away at a few important features and improvements for this release, so buckle up and get ready for a ride 🚀 (click here for a quick breakdown of all changes)

New Feature: serverBuildTarget

In v1.2 we are doubling down on the power—and improving the simplicity—of integrating your server with your app. This release introduces a new config option serverBuildTarget that removes some of the overhead of configuring Remix to interface with your deploy target, and it's an important first step towards being able to move your application with greater ease as requirements change.

When you specify a build target, Remix will take care of configuring other details like the build directory and module format. serverBuildTarget supports a number of deployment platforms and runtimes:

  • "node-cjs"
  • "arc"
  • "netlify"
  • "vercel"
  • "cloudflare-pages"
  • "cloudflare-workers"
  • "deno" 👀

If this option is not set, your app works exactly as it did before. If you bootstrapped your app with the Remix App Server or are using your own Node server, we suggest setting this option to "node-cjs".

New Feature: Single-file server builds

In addition to simplifying server configuration, we've also introduced a way for users to compile their server along with their app using the new server config option. This setting is optional, points to the path of your custom server, and allows Remix to compile your server and app to a single file.

What does this mean for you? If you are deploying to Cloudflare Workers, this allows you to remove the secondary build step, as our compiler takes care of everything for you. It also means you can write your custom server in TypeScript 🥳

Custom server code example
// remix.config.js
module.exports = {
  server: "./server.ts"
};

// server.ts
import express from "express";
// Import the output of your server build from a Remix virtual module
import * as serverBuild from "@remix-run/dev/server-build";

let app = express();
app.all(
  "*",
  createRequestHandler({
    build: serverBuild
  })
);

If this option is not set, your app works as it did before, and you will continue to import the output from your server build directory instead of our new virtual module. Also note that with this new capability we have deprecated serverBuildDirectory and suggest that you use serverBuildPath instead.

New Feature: Browser shims for Node built-ins

Remix can now add polyfills for built-in node_modules in the browser. This is really useful if you need to access utilities like path or read from process in your client code. It should also make migrating your Webpack projects to Remix a breeze.

These shims are only used if you use Node built-ins in client code. Remix already tree-shakes server code out of your client bundles, so if you don't use these modules outside of your loaders and actions this won't change anything for you. But it can prevent nasty failures at runtime if you do!

New Feature: Using ESM-only packages on node

We added a serverDependenciesToBundle config option that tells Remix which dependencies to include in your server bundle when using the node-cjs build target. This allows you to use packages that publish only ESM in your CommonJS output.

Using ESM-only packages on node
// remix.config.js
module.exports = {
  serverDependenciesToBundle: [
    "remark"
  ]
};

🧪 Experimental Feature: Deno adapter

If you've read this far, you may have noticed an interesting little detail in our new serverBuildTarget options. We now provide an adapter package to deploy to Deno, and we've added this option to the create-remix CLI 🤯

We are very excited about Deno and bullish on its future, so providing first-class support is a huge step towards supporting the Deno ecosystem. It's still the early days in this space and we'd love your help battle testing our adapter to make Remix and Deno a rock-solid force to be reckoned with. 💪


TLDR: What Changed?

✨ Features

  • New serverBuildTarget config option to specify your deployment target and simplify integration with your Remix adapter
  • New server config option that allows us to compile your server and app into a single file. This allows for simpler deployment, as well as eliminating the secondary build step for users deploying to Cloudflare Workers or writing their server code in TypeScript.
  • Add DynamoDB tables session storage for @remix-run/architect (#1538)
  • 🧪 EXPERIMENTAL New Deno adapter! You can now install @remix-run/deno or bootstrap your app by selecting deno in the create-remix CLI.

💅 Enhancements

  • Dev server should watch remix.config.js server file (#1605)
  • remix dev should now find an available port if the default port isn't available (#871 + #1352)
  • process.env.NODE_ENV check is no longer needed for <LiveReload /> (#1352)
  • Added support for binary data responses in @remix-run/architect and @remix-run/netlify (#1780)
  • Implemented a minimum version check for Node to prevent confusing crash logs (#1586)
  • Lots of error message improvements! 🙏

🐛 Bug fixes

  • Allow for streams to be returned as the response body in @remix-run/vercel (#1470)
  • Fix forwarding of request cookie headers in @remix-run/architect (#1709)
  • Fix a bug preventing remix dev and remix serve from running offline (#1743)
  • Fix support for submit buttons outside of their form element in <Form> (#1781)
  • Fix both Link and NavLink to ensure prefetch works with explicit event handlers by (#1783)
  • Add Netlify-specific context to Remix server actions when used with @remix-run/netlify (#1835)
  • Fix a bug where numerical URL targets caused sites to hang and crash (#936)
  • Fix the DynamoDB key for arcTableSessionStorage and deleteData in @remix-run/architect (#1863)
  • Fix a bug where FormData methods would return null for empty strings (#1869)
  • Fixed a bug where a button's data was missing if the user clicked on a nested element inside the button (#1240)
  • Reset useFetcher().submission state back to "idle" after a redirect (#1875)
  • Fixed native _redirects support for Cloudflare Pages by (#1237)
  • Added missing statusText to responses in @remix-run/express and @remix-run/vercel (#1234)

☠️ Deprecated

  • remix.config.js
    • serverBuildDirectory is deprecated; use serverBuildPath instead
    • serverModuleFormat and serverPlatform are both deprecated; use serverBuildTarget instead

New Contributors

Full Changelog: v1.1.3...v1.2.0