A fast, smart, & global CDN for modern(es2015+) web development.
MIT License
Bot releases are hidden (Show)
in v115, we added ?module
query to allow you import .wasm
as a WebAssembly.Module
Object:
import wasm from "https://esm.sh/@dqbd/[email protected]/tiktoken_bg.wasm?module"
const { exports } = WebAssembly.instantiate(wasm, imports)
Changelog:
?module
query with .wasm
files@types/node
to 18In v114, we switched to pnpm instead of yarn which can save the server disk space and improve the build performance significantly, and now the server can handle package files of private registry (thanks @Justinidlerz for contributing to this).
We upgraded esbuild to 0.17.14, and a new query ?conditions
added as conditions option of esbuild:
import foo from "https://esm.sh/foo?conditions=custom1,custom2"
For Deno users, we fixed some incorrect/missed types. Thanks for @marvinhagemeister making him first great PR to this project.
Changelog:
?conditions
query as esbuild option.d.mts
extension (close #580)The CDN serves over 5M requests each day currently, which is powered by Cloudflare's edge worker, it's globally fast! (you can check the benchmark by @azu: https://github.com/azu/npmcdn-upptime).
Changes:
.mjs
extension for the package main module to resolve sub-path conflicts?exports
query when importing stable modulesrequireModeAllowList
(close #540, #548)For Deno:
XHR
polyfill for axios
, cross-fetch
, whatwg-fetch
automaticallynode:buffer
import for denonext
target (closed #556)Huge thanks to @Justinidlerz @npg418
deprecated
messagetarget
optionupdate
command (close #536)Before when you import a module without specifying the package version like "https://esm.sh/react", it will redirect to latest version like "https://esm.sh/[email protected]", that means it needs to ask the NPM registry what the latest version of the package every time, in v111 we added a cache layer for the NPM registry to improve the redirect response time. Since we set the cache TTL to 10 minutes, so you may get the delay of the package latest update, but for a CDN the response time is the most important care-thing, the best practice is always point out the full version of packages like "https://esm.sh/[email protected]".
?external
option for stable buildsreact/jsx-runtime
bundles react
moduledenonext
target to use deno 1.31 node compatibility layer, we will switch to the denonext
target as default for deno once deno deploy supports node:
specifier.
import "https://esm.sh/your-package?target=denonext"
https://esm.sh/normalize.css -> https://esm.sh/normalize.css/normalize.css
import init, { transform } from "https://esm.sh/lightningcss-wasm";
// v107: you need to specify the wasm URL
await init("https://esm.sh/lightningcss-wasm/lightningcss_node.wasm")
// v108: you don't need to specify it
await init()
bundle
mode for stable buildsHuge thanks to @jaredcwhite
?cjs-export
query (close #512)...not provide an export named...
, that means esm.sh can not resolve CJS exports of the module correctly. You can add ?cjs-exports=foo,bar
query to specify the export names:
import { NinetyRing, NinetyRingWithBg } from "https://esm.sh/[email protected]?cjs-exports=NinetyRing,NinetyRingWithBg"
requireModeAllowList
(close #520)?sourcemap
query, always generate source map as inline url.esbuild
to 0.17.10.deno/std
to 0.177.0
Huge thanks to @Justinidlerz @zookatron
inject
argument for worker factory, this is useful if you want to importScripts
in the worker, but the module worker doesn't allow you to do it.
import workerFactory from "https://esm.sh/[email protected]?worker";
const workerInject = `
self.onmessage = (e) => {
// variable 'E' is the xxhash-wasm module default export
E().then(hasher => {
self.postMessage(hasher.h64ToString(e.data));
})
}
`;
const worker = workerFactory(workerInject);
worker.onmessage = (e) => {
console.log(e.data); // 502b0c5fc4a5704c
};
worker.postMessage("Hello");
?external
arg in bundle mode (close #498)require()
syntax support for dts transformerbasePath
doesn't take effect on redirects (close #481)X-TypeScript-Types
header not pined for stable buildsesbuild
to 0.16.17
deno/std
to 0.173.0
Huge thanks to @goloveychuk @ahuigo @hjaurum @kidonng
Support browser
field of package.json to improve compatibility with npm packages in browser. For example, the webtorrent
package will use memory-chunk-store
instead of fs-chunk-store
and exclude built-in modules like fs
, net
, os
and so on.
{
"name": "webtorrent",
"description": "Streaming torrent client",
"version": "1.9.6",
"browser": {
"./lib/server.js": false,
"./lib/conn-pool.js": false,
"./lib/utp.js": false,
"bittorrent-dht/client": false,
"fs": false,
"fs-chunk-store": "memory-chunk-store",
"load-ip-set": false,
"net": false,
"os": false,
"ut_pex": false
},
}
(Close #450)
?bundle
mode with illegal paths (close #476).?worker
mode doesn't support CORS.Published by ije almost 2 years ago
🎉🎉🎉 We just updated the esm.sh website with brand-new design for the v100 release, please take a look!
https://esm.sh
And we also added a playground app that allows you to play ESM in browser without build tools.
https://playground.esm.sh
browser
field when it's an es6 module (close #381).Access-Control-Allow-Origin
header (close #453).esbuild
to 0.16.10.deno/std
to 0.170.0.Huge thanks to @hjaurum @chrisirhc @ThaUnknown @rxliuli
.d.ts
, .wasm
and other static files.?deps
purge (close #422).?exports
query of sub build task.deno/std
to 0.165.0.import { __await, __rest } from "https://esm.sh/tslib" // 7.3KB
import { __await, __rest } from "https://esm.sh/tslib?exports=__await,__rest" // 489B
node-fetch
polyfill for browsers and denoexports
resolver (close #422)ns
process when got "unreachable" error (close #448)swc
to latestPublished by ije almost 2 years ago
https://esm.sh/build-target
endpoint to return the compatible target
of current browser/runtime by checking User-Agent
header, lowest is es2015
.--npm-token
option for the server to support private packages (#435).polyfills/node_process
: replace timeout with queueMicrotask
(#444).deno/std
to 0.162.0.Huge thanks to @Justinidlerz @ThaUnknown
fs
ployfill for browsers(add createReadStream
and createWriteStream
methods)