Architect 10 (Taniwha): plugins, TypeScript, live reloads, and much more

Ryan Block’s avatar

by Ryan Block
@ryan
on

We are delighted to introduce you to Architect 10 (Taniwha), one of our biggest releases ever. We spent over two years listening to feedback, researching, and experimenting with new ways to extend Architect beyond its current capabilities to help you build simple, powerful, maintainable Functional Web Apps (FWAs).

Install it now: npm i @architect/architect@latest

Plugins

Architect 10 (Taniwha) features a fast, capable, highly extensible plugin API that enables you to drop in custom Lambdas of any kind, ship fully-baked, prepackaged application features, programmatically generate your application’s Lambdas, and much more. The Architect 10 plugin API enables:

  • Dynamic control of any Lambda pragma, so you can return a single event or a large set of HTTP routes (and everything in between)
  • Custom, targeted environment variables
  • Arbitrary data payloads (up to 4KB) to be loaded on-demand via @architect/functions
  • Custom runtimes, including TypeScript support
  • Hooks into the deployment lifecycle, Sandbox lifecycle, and Sandbox file watcher
  • Ship Architect projects to AWS intermediaries (like Begin or Serverless Cloud), or even to non-AWS clouds

Writing plugins is about as simple as we could make it. Let’s create a custom HTTP handler; first add this to your project manifest (e.g. app.arc):

@plugins
my-plugin

Then scaffold a fresh plugin with npx arc init --plugin my-plugin, and finally we’ll just drop in some code:

module.exports = {
  set: {
    http: (params) => {
      // You can also return an array of routes to create more than one
      return {
        method: 'get',
        path: '/my-custom-endpoint',
        // Points to the index.js handler you'd like to run your custom HTTP Lambda
        src: './handler-src'
      }
    }
  }
}

That’s it! Now you’ve got an HTTP endpoint that will be treated just the same as if get /my-custom-endpoint had been added to the project manifest.

To help you find plugins (and drive exposure to any plugins you may create), we’ve also started a list of Architect plugins – send us a PR whenever you publish one!

TypeScript support

We know how many folks love TypeScript, so we designed our plugin API to ensure we could deliver first-class TS support. Author your functions in TS (with your own tsconfig.json), and Architect automatically transpiles your Lambdas in real time, sourcemaps baked right into your testing and staging (and, optionally, production) environments. Try it out:

git clone https://github.com/architect-examples/typescript-example
cd typescript-example && npm i
npm run start

Then try editing (or throwing an error in) src/http/get-index/index.ts. (Don’t forget to check out the automatically generated sourcemaps in .build/http/get-index/.)

We think this may well be among the best TypeScript experiences you’ve ever seen on Lambda, or even possibly AWS. Learn more about Architect + TypeScript here.

Sandbox live reload

Folks tell us all the time that Architect Sandbox is an incredibly fast way to iterate locally, and we’ve continued to hear feedback that it could be even faster by adding live reload functionality – so that’s exactly what we did.

To try it out, add the following to your Architect preferences file (e.g. prefs.arc):

@sandbox
livereload true

Now, every local HTML response (with a <head> tag) that your application delivers will enable your browser to instantly automatically refresh any time there’s a filesystem change detected in any HTTP get + any Lambdas, or shared or views code. We used this feature to ship a refreshed design of the Architect web site and it was truly a delight.

Sandbox automatic port selection

It turns out a lot of folks run multiple Architect projects at a time on their local machines (which is great!). To achieve our goal of fully local, offline emulation of production Architect apps, Sandbox uses a variety of internal ports for various services (like DynamoDB, WebSockets, etc.).

In Architect 10, those internal ports no longer conflict – just set your main HTTP port (if you’re using @http) and Architect will take care of the rest itself. (Of course, you’re still welcome to customize those internal ports, should you need to.)

Leaner and faster

We tidied up quite a bit around Architect, optimizing and improving workflows, and removing unnecessary legacy code and cruft. And @architect/functions, our Node.js runtime library, is now 50% smaller in version 5, and up to 10x faster to use (depending on which features you take advantage of).

Upgrading

As is the Architect approach, we strive to batch and isolate our breaking changes, and to provide equivalent remedies wherever possible. (For example: Architect 10 removes support for the legacy .arc-env local env var file originally deprecated in 2020, but has support for .env files and a more expansive pref[erences].arc file.)

While we expect nearly everyone should be able to seamlessly upgrade from Architect 6+ to Arc 10, we strongly advise you to review the Architect 10 upgrade guide before making any changes to your production applications.

Acknowledgments

Weighing in at a nearly 23,000 line diff, Architect 10 is our most expansive release since Architect 6 (Ogopogo, 2019), possibly ever. We’re humbled and inspired by the thousands of developers that rely on Architect to deliver their applications, and grateful for their trust – and especially their feedback, support, and good vibes. We simply could not ship releases of this scale without the amount of input and testing we get from the greater Architect community. Thank you!

If you haven’t already, don’t forget to join them (and us) in the Architect Discord!

Finally, we’d like to thank our wonderful friends at AWS, within the broader serverless FWA community, and Rebecca Gibbs, who kindly illustrated our Taniwha.

The Taniwha

The Taniwha

“Taniwha are supernatural creatures in Māori tradition (the indigenous people of Aotearoa), similar to serpents and dragons in other cultures. They were said to hide in the ocean, rivers, lakes or caves. Some Taniwha were dangerous to people. Others were believed to be guardians for a tribe, and people would offer them gifts or prayers. Although many Māori today do not believe in Taniwha, they continue to hold great significance in te ao Māori (the Māori world).” –Te Ara

Art + words by Rebecca Gibbs