Releases: esm-dev/esm.sh
v136
-
Add two builtin registries:
- jsr - The open-source package registry for modern JavaScript and TypeScript, created by the Deno team. (32cd2bd)
// example import { encodeBase64 } from "https://esm.sh/jsr/@std/[email protected]/base64"; import { Hono } from "https://esm.sh/jsr/@hono/hono@4";
- pkg.pr.new - Continuous (Preview) Releases for your libraries, created by StackBlitz Labs (#904, #913)
// Examples import { Bench } from "https://esm.sh/pr/tinylibs/tinybench/tinybench@a832a55"; import { Bench } from "https://esm.sh/pr/tinybench@a832a55"; // --compact
- jsr - The open-source package registry for modern JavaScript and TypeScript, created by the Deno team. (32cd2bd)
-
BREAK CHANGE: Respect semantic versioning for dependency resolving (#875)
Previously, dependency resolution used fixed versions, which could cause duplication issues when packages were updated. Starting from v136, we now follow semantic versioning for dependencies.
// before "[email protected]" import "/[email protected]/es2022/react.mjs"; // after "[email protected]" import "/react@^19.0.0?target=es2022";
-
BREAK CHANGE: Remove build version prefix from the module path
The build version prefix of esm.sh was introduced to avoid potential breaking changes caused by updates to the esm.sh server. However, it can lead to duplication issues when updating the server. In v136, we have removed the build version prefix from the module path, and the
?pin
query will be ignored. Paths with the build version prefix will continue to work as before, but the new default will be paths without the build version prefix.// before "[email protected]" -> "https://esm.sh/v135/[email protected]/es2022/react.mjs"; // after "[email protected]" -> "https://esm.sh/[email protected]/es2022/react.mjs";
-
Add built-in npm package manager (#948)
Implement a built-in npm package manager in Go to replace pnpm. This change reduces the CI test time from 12:15 to 4:30 (~2.7x faster) and eliminates the need for
nodejs
andpnpm
dependencies. -
Split modules by analyzing the dependency tree during the build process (#959)
To improve build performance and reduce network requests, esm.sh bundles sub-modules of a package by default. However, this can lead to duplicate code in the build. In v136, the server will split the modules by analyzing the dependency tree during the build process if the package's
exports
field is defined. -
Use @pi0's unenv as the node runtime compatibility layer (#914)
unenv provides a collection of Node.js and Web polyfills and mocking utilities with configurable presets for converting JavaScript code and libraries to be platform and runtime agnostic, working in any environment including Browsers, Workers, Node.js, Cloudflare Workers, Deno. unenv is also used by CloudFlare Workers: blog.
You can also access these
unenv
node runtime modules directly via/node/[node-builtin-module-name].mjs
path, for example:import * from "https://esm.sh/node/fs.mjs";
-
Add npm-replacements that follows e18e's module-replacements. (#914)
The
npm-replacements
package replaces certain polyfill packages on NPM with native modern APIs during the build process. For example, theobject-assign
package is replaced withObject.assign
:import assign from "object-assign"; // replaced with "const assign = Object.assign"
-
Deprecate the
build
APIimport { build } from "https://esm.sh/build"; build() // throws Error: The build API has been deprecated.
-
Deprecate the Deno CLI script
Deno now includes its own built-in package manager, which can be used to manage
jsr:
nadnpm:
imports in your deno applications. So we decided to deprecate the Deno CLI script.# use deno add npm:preact jsr:@std/encoding Add npm:[email protected] Add jsr:@std/[email protected] # do not use deno run -A -r https://esm.sh init error: The deno CLI has been deprecated.
-
Add
npmScopedRegistries
configThe
npmScopedRegistries
configuration enables you to define the registry, token, user, and password for scoped npm packages. This allows you to import scoped packages using URLs likehttps://your-esm-server.com/@scope_name/pkg@version
.{ "npmScopedRegistries": { "@scope_name": { "registry": "https://your-registry.com/", "token": "xxxxxx", "user": "", "password": "" } } }
-
Experimental Features:
- Build
.vue
and.svelte
files on the fly (#906)import "https://esm.sh/gh/phosphor-icons/[email protected]/src/icons/[email protected]"
- https://esm.sh/x - ts/jsx/vue/svelte just works™️ in browser. (#886)
- Build
-
Other Changes:
- Upgrade esbuild to 0.24.2
- Use native [email protected]
- Use target
es2022
for browsers by default (#903) - Replace
window
withglobalThis
to make Deno 2 happy (#964) - Use
.mjs
extenstion for sub-module build (#917) - dts-transformer: support
.d
andd.cts
extension (#987) - Support
major.minor.patch+build
versioning (#985) - Support import attributes (#976)
- config: Support S3-compatible storage (#886)
- config: Add
corsAllowOrigins
config - config: Add
customLandingPage
config (#928) - config: Add
npmQueryCacheTTL
config (#921)
v135 / Introducing esm.sh/run
🎉🎉🎉 Introducing esm.sh/run, a 1KB script allows you to write jsx/tsx
in HTML without build step!

Installation
<script type="module" src="https://esm.sh/run"></script>
Usage
The script allows you to add <script>
elements with jsx/typescript in your HTML, for example:
<script type="text/babel">
console.log("esm.sh run!" as string)
</script>
Supported types:
text/babel
(recommended, highlighting is working in vscode)text/jsx
text/ts
text/tsx
Using Import Maps
esm.sh run supports import maps, it even works in outdated browser that doesn't support the feature.
<script type="importmap">
{
"imports": {
"@jsxImportSource": "https://esm.sh/[email protected]",
"react-dom/client": "https://esm.sh/[email protected]/client"
}
}
</script>
The special
@jsxImportSource
in theimports
is using for JSX transform, you can alternate it to your preferred runtime, for examplehttps://esm.sh/[email protected]
.
How it Works?
After the page loaded, the run script computes the hash of the source code of non-javascript <script>
elements as the cache key, if the cache exists then run it, otherwise sends the source code to esm.sh build API and stores it in the cache system.
The cache system includes two iters of storage, are the localStoarge
and Cloudflare Edge cache, to make the compiled JS load fast!
Limitations
There are some limitations you need to be aware of:
- the build task is slower than local babel/swc/esbuild (only happens when the source code has been changed)
- 60 build tasks pre minute is allowed
Try it Online
Other changes
v134
esm.sh v134 mainly includes some bugfix patches. And now you can add allowList option to serve specific packages on you self-hosting esm.sh server. (Thanks @olekenneth for contributing to this!)
Changelog
- Add
transformOnly
option for build api - Add
allowList
in config (#745 by @olekenneth) - Improved Deno CLI (#742 by @Kyiro)
- Worker: fix dist version lookup
- Fix exported names from a dependency (close #729, #750)
- Fix: write
.npmrc
file ifNpmRegistry
is set (close #737) (#751 by @edeustace) - Upgrade esbuild to 0.19.5
v133
In v133, we introduced the ?raw
mode that returns the raw JS files and fixed a bunch of bugs.
Escape Hatch: Raw Source Files
In rare cases, you may want to request JS source files from packages, as-is, without transformation into ES modules. To do so, you need to add a ?raw
query to the request URL.
For example, you might need to register a package's source script as a service worker in a browser that does not yet support the type: "module"
option:
await navigator.serviceWorker.register(
new URL(
"https://esm.sh/[email protected]/playground-service-worker.js?raw",
import.meta.url.href
),
{ scope: '/' }
);
You may alternatively specify an &raw
extra query after the package version:
<playground-project sandbox-base-url="https://esm.sh/[email protected]&raw/"
></playground-project>
so that transitive references in the raw assets will also be raw requests.
Thanks @johnyanarella for contributing to this.
Changlog:
- Add
?raw
to support requests for raw package source files (#731 by @johnyanarella) - Add global
setMaxListeners
tonode:events
polyfill (#719) - cjs-lexer: resolving error now doesn't break build (close #738)
- Fix
cwd
method ofnode:process
polyfill (close #718) - Fix
applyConditions
function usenode
condition for browser (close #732) - Fix
*.css.js
path (close #728) - Fix some invalid require imports (close #724)
- Fix relative path resolving of
browser
in package.json - Upgrade esbuild to 0.19.4
v132
In v132, no features are added but some bugs have been fixed.
Changelog:
v131
In v131, we improved the /build
API to avoid duplicated builds of same input code, and fixed some bugs:
v130
esm.sh v130 improves the esm-cjs-lexer to get correct exports
of a minified UMD module, this can fix error "missed named exports" of some cjs only packages. The great change was contributed by @lewisl9029, huge thanks ❤️
Changelog:
- esm-cjs-lexer: support minified UMD exports (#689 @lewisl9029)
- Fix sub
.mjs
module (close #691) - Fix playground (https://code.esm.sh) editor don't load language workers
- Fix
?bundle
mode ignoresnode_process.js
(close #694) - Upgrade
@types/react@18
to 18.2.15 - Upgrade
esbuild
to 0.18.17
v129
esm.sh v129 mainly inclueds some bug fixs:
- BREAKING: Remove
X-Esm-Deps
header (close #683) - Sort
exports
of package.json when looping (close #683) - Don't replace
typeof window
for deno target (close #681) - Don't replace node global variable for
?target=node
- Fix dts transformer (close #670)
- Fix depreacted message with
"
- esm-worker: Fix
cacheKey
withX-Real-Origin
header
v128
In v128, we added an official Docker image to allow you to self-host esm.sh more easily (This is based on johnpangalos/docker-esm-dot-sh by @johnpangalos, thank you!).
docker pull ghcr.io/esm-dev/esm.sh
More usage check HOSTING.md
For Deno users, we upgraded stableBuild to latest(v128) this may break your deno.lock.
Changelog
- Add official Docker image: https://ghcr.io/esm-dev/esm.sh
- Fix missed
?external
for deps - Fix duplicate
Access-Control-Expose-Headers
headers - Fix dts transform for imports with both default and named imports (#675 by @hayes)
- Don't bundle dynamic imports
- BREAKING Upgrade stableBuild to v128
v127
In v127, we improved the network waterfall by adding the dependency imports of current module in the entry module (aka. preload).
For example: https://esm.sh/[email protected]
import "https://esm.sh/stable/[email protected]/es2022/react.mjs"; /* Added in v127 */
import "https://esm.sh/v127/[email protected]/es2022/scheduler.mjs"; /* Added in v127 */
export * from "https://esm.sh/v127/[email protected]/es2022/react-dom.mjs";
export { default } from "https://esm.sh/v127/[email protected]/es2022/react-dom.mjs";
For framework authors, esm.sh provides an extra X-Esm-Deps
header that allows you to get those preload import urls.
const res = await fetch("https://esm.sh/[email protected]")
console.log(res.headers.get(`X-Esm-Deps`)?.split(", "))