Introducing 4.0!

do4ng - 25-06-22

It has been seven months since 4.0.0-next.0 was released. This new version brings both feature updates and major internal performance improvements. Here’s a summary of everything that has changed.

#Performance

In line with zely's philosophy, performance has been dramatically improved.

Compared to previous versions, the latest update significantly reduces latency and nearly triples throughput (requests/sec and bytes/sec). This level of performance leap is not just a minor improvement—it redefines how lightweight servers can operate at scale.

👉 View Full Benchmark History

PERFORMANCE

PkgLatencyRequests/SecBytes/Sec
4.0.0:serpack-on (latest)0.02 ms19.5K2.49 MB
4.0.0:serpack-off (latest)0.01 ms19.5K2.49 MB
3.0.01.06 ms6.5K848.84 KB
2.0.0-next.240.1 ms12.7K1.63 MB
1.0.00.02 ms18.7K2.39 MB

Even when serpack is enabled, there is no noticeable performance loss, proving that the new compiler is lightweight enough for production environments.

#New Compiler

zely now supports a new compiler to allow for more flexibility in future updates. Although esbuild remains the default loader, zely introduces serpack, a custom loader built on top of swc.

Terminal
zely dev --serpack

While serpack is slightly less performant than esbuild (but still fast!), it is tightly optimized for zely's internal systems and unlocks powerful features not available with esbuild.

WARNING

Although serpack is mostly stable, undiscovered issues may still occur.

#Server Build

You can now compile and deploy your zely-powered server as JavaScript.

The old version of build feature (provided by @zely/builder) became incompatible after 3.0 due to internal changes, but the feature is now back in 4.0—completely rebuilt.

While the original builder only copied and transpiled the server, the new build system routes all requests directly through the zely server runtime.

For details, refer to the build documentation.

#$store

$store is a server-side cache utility.

It runs the given callback function only once, caches the result, and reuses it for 3 minutes.

Typescript
import { GET } from '@zely-js/core';
import { setTimeout } from 'timers/promises';
 
async function greeting() {
  await setTimeout(1000);
  return 'Hello, Doe!';
}
 
export default [
  GET(async (ctx) => {
    const { data } = await $store(greeting);
    ctx.send(data);
  }),
];

$store is already globally declared, so you don’t need to import it manually.

WARNING

Since $store internally depends on features provided by serpack, please activate it using the --serpack flag when running your server.

#Frontend Support (Experimental)

Note: This is an experimental feature for upcoming frontend support.

The new HTML loader compiles the HTML file instead of directly serving it, improving responsiveness and enabling future extensibility. Learn more

Enable the loader with experimental.useHTML in zely.config.ts:

zely.config.ts
import { defineConfig } from 'zely';
 
export default defineConfig({
  experimental: {
    useHTML: true,
  },
});

INFO

Example: simple counter

#CLI Request Tool

No need to write temporary scripts to test your server during development.

Plain
$ zely request
 
▸ baseURL: http://localhost:3001
 
[12:31:35 AM] info checking server... (requesting /)
 
GET> /
200 {"msg":"Hello","name":""}
GET>

You can also use JavaScript to configure method, headers, and body inline:

Plain
GET> config1 = { method: "POST", headers: { }, body: { name: "Cat" } }
GET> set(config1)
POST(config1)> /greeting
200 Hello, Cat!

TIP

Declare variables without using const or let—just type them directly in the prompt.

#Debugging

Check the debugging documentation for more details.

#Conclusion

This release makes zely faster, more modular, and ready for future features like frontend rendering and build-time optimizations. With the introduction of serpack, a new compiler architecture, and the return of server builds, zely is growing beyond just a micro-framework—it’s evolving into a complete platform for building fast, modern web applications.

Give it a try and let us know what you think.