Forem

Cover image for Introducing: ESM CDN for NPM + Deno
X.
X.

Posted on • Edited on

12 4

Introducing: ESM CDN for NPM + Deno

Hi, let me introduce you to esm.sh, a fast, global content delivery network (CDN) for modern(es2015+) web development that allows you to import es6 modules from a URL:

import React from 'https://esm.sh/react'
Enter fullscreen mode Exit fullscreen mode

Specify version

import React from 'https://esm.sh/react@17.0.1'
Enter fullscreen mode Exit fullscreen mode

Submodule

import { renderToString } from 'https://esm.sh/react-dom/server'
Enter fullscreen mode Exit fullscreen mode

Deno compatibility

esm.sh will polyfill the node internal modules(fs, os, etc..) with https://deno.land/std/node to support some modules to work in Deno, like postcss:

import postcss from 'https://esm.sh/postcss'
import autoprefixer from 'https://esm.sh/autoprefixer'

const css = (await postcss([ autoprefixer]).process(`
    backdrop-filter: blur(5px);
    user-select: none;
`).async()).content
Enter fullscreen mode Exit fullscreen mode

X-Typescript-Types

By default, esm.sh will response a custom HTTP header of X-TypeScript-Types when the types(dts) defined, that is useful for Deno types check (link).

Alt Text

More usages

Please check https://esm.sh

Open source

esm.sh is licensed under the MIT License.

https://github.com/esm-dev/esm.sh

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more