DEV Community

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

Posted on • Updated on

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

Top comments (0)