A fast, global content delivery network and package manager for ES Modules

A fast, global content delivery network and package manager for ES Modules

A fast, global content delivery network and package manager for ES Modules. All modules are transformed to ESM by esbuild from npm.

ESM

A fast, global content delivery network and package manager for ES Modules. All modules are transformed to ESM by esbuild from npm.

Import from URL

import React from 'https://esm.sh/react'

Specify version

import React from 'https://esm.sh/[email protected]'

Submodule

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

Specify ESM target

import React from 'https://esm.sh/react?target=es2020'

Avaiable target: es2015 - es2020, esnext

Development mode

import React from 'https://esm.sh/react?dev'

Bundle mode

import React from 'https://esm.sh/[react,react-dom]/react'
import ReactDom from 'https://esm.sh/[react,react-dom]/react-dom'

or your can define bundle list in the import-map.json (import-maps proposal)

{
    "imports": {
        "https://esm.sh/": "https://esm.sh/[react,react-dom]/",
        ...
    }
}
import React from 'https://esm.sh/react' // actual from 'https://esm.sh/[react,react-dom]/react'

⚠️ The bundling packages in URL are litmited up to 10, to bundle more packages, please use the esm client.

Proxy mode

import P from 'https://esm.sh/${provider}/[email protected]/path/to/file'

Avaiable provider: deno.land, nest.land, x.nest.land, denopkg.com Simply proxy all the providers in the import-map.json:

{
    "imports": {
        "https://deno.land/":   "https://esm.sh/deno.land/",
        "https://nest.land/":   "https://esm.sh/nest.land/",
        "https://x.nest.land/": "https://esm.sh/x.nest.land/",
        "https://denopkg.com/": "https://esm.sh/denopkg.com/",
        ...
    }
}

ESM Client in Deno [WIP]

# install esm command
deno install --allow-read --allow-write --allow-net -f -n esm https://deno.land/x/esm/cli.ts

# set cdn
$ esm config cdn cdn.ems.sh.cn

# add some packages
$ esm add react react-dom

# specify version or tag
$ esm add [email protected]
$ esm add [email protected]

# remove some packages
$ esm remove lodash

# update installed packages to latest version
$ esm update

# help message
$ esm -h

X-Typescript-Types

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).

figure #1

Caveats

Different with Skypack and jspm, esm.sh will bundle all dependencies(exclude peerDependencies) for each package, that means there may be redundant contents transmitted when you are importing multiple packages. This should be improved when the http/3(quic) is ready. For now the best practice is using the bundle mode.

Self-Hosting

You will need Go 1.14+ to compile the server, and ensure supervisor installed on your host machine. The server runtime will check the nodejs installation (12+) exists or install the latest LTS version automatically.

$ git clone https://github.com/postui/esm.sh
$ cd esm.sh
$ sh ./scripts/deploy.sh

Download Details:

Author: postui

Source Code: https://github.com/postui/esm.sh

deno node nodejs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings