Skip to content

v120

Compare
Choose a tag to compare
@ije ije released this 10 May 12:29
· 901 commits to main since this release

In v120, we open-sourced the Cloudflare worker that reveals how we handle 10M requests pre day at edge(earth). You can use it to build your own fast CDN easily:

import worker from "esm-worker";

export default worker((req, ctx) => {
  // your routes override esm.sh routes
  if (ctx.url.pathname === "/") {
    return new Response("<h1>Welcome to use esm.sh!</h1>", {
      headers: { "content-type": "text/html" },
    });
  }
})

More details please check esm-worker.

We improved the build API allows you to add types for your modules, it's useful for types checking and lsp completion:

import { build } from "https://esm.sh/build"

const { url } = await build({
  dependencies: {
    preact: "^10.13.2",
  },
  code: `
    export { h } from "preact";
  `,
  types: `
    export { h } from "preact"
  `,
})

Changelog:

  • build-api: Support types option
  • Open-source the cloudflare worker
  • Support HEAD method
  • Use empty object instead of null for browser exclude (close #613)
  • Add zlib-sync to nativeNodePackages (close #621)
  • Fix bare path for css/custom build
  • Fixing type only packages missing the X-Typescript-Types header
  • cjs-lexer: Fix exports resloving
  • Redirect invalid *.json url