Skip to content

Commit 3b725a3

Browse files
authored
Release v137 (#1312)
1 parent ac4e88e commit 3b725a3

156 files changed

Lines changed: 639 additions & 470 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG-CLI.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# CLI Changelog
2+
3+
## v0.1.0
4+
5+
Introduce `esm.sh` CLI, a _no-build_ tool for modern web development. Features include:
6+
7+
- Initialize a new no-build web app with esm.sh CDN
8+
- Serve web apps with esm.sh CDN, HMR, transforming TS/Vue/Svelte on the fly
9+
- Maintain the `importmap` script in index.html
10+
11+
## Installation
12+
13+
Install `esm.sh` CLI via curl:
14+
15+
```bash
16+
curl -fsSL https://esm.sh/install | bash
17+
```
18+
19+
To install `esm.sh` CLI from source code, you need to have [Go](https://go.dev/dl) installed.
20+
21+
```bash
22+
go install github.com/esm-dev/esm.sh
23+
```
24+
25+
Or install `esm.sh` CLI via `npm`:
26+
27+
```bash
28+
npm install -g esm.sh
29+
```
30+
31+
Or use `npx esm.sh` without installation:
32+
33+
```bash
34+
npx esm.sh [command]
35+
```
36+
37+
### Usage
38+
39+
```
40+
$ esm.sh --help
41+
Usage: esm.sh [command] [options]
42+
43+
Commands:
44+
add [...imports] Add imports to the "importmap" script in index.html
45+
tidy Clean up and optimize the "importmap" script in index.html
46+
init Initialize a new no-build web app
47+
serve Serve the web app in "production" mode
48+
dev Serve the web app in "development" mode with live reload
49+
50+
Options:
51+
--version, -v Show the version
52+
--help, -h Display this help message
53+
```

CHANGELOG.md renamed to CHANGELOG-SERVER.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,54 @@
1-
# Changelog
1+
# Server Changelog
2+
3+
## v137
4+
5+
* Introduce `esm.sh/x` - ts/jsx/vue/svelte just works™️ in browser.
6+
```html
7+
<!-- use build tools like Vite, Webpack, etc. -->
8+
<script type="module" src="app.tsx"></script>
9+
10+
<!-- use esm.sh/x without build tools -->
11+
<script src="https://esm.sh/x" href="app.tsx"></script>
12+
```
13+
* Introduce date(`yyyy-mm-dd`) versioning
14+
```js
15+
import * as myPackage from "https://esm.sh/my-package@2026-01-02";
16+
```
17+
* Introduce `?meta` API that allows you to get the module build metadata.
18+
```
19+
$ curl https://esm.sh/react?meta
20+
{
21+
"name": "react",
22+
"version": "19.2.4",
23+
"module": "/react@19.2.4/es2022/react.mjs",
24+
"integrity": "sha384-xPv1wRGmRBj4tIrN16FDkSIeMntFCfG+8ptsnx5wqrM+0zp/oKtoyJ0QqCJAAeVm",
25+
"dts": "/@types/react@~19.2.9/index.d.ts",
26+
"exports": ["./jsx-runtime", "./jsx-dev-runtime", "./compiler-runtime"],
27+
}
28+
```
29+
* Other Changes:
30+
* Upgrade `esbuild` to 0.27.3
31+
* Upgrade `unenv` to 2.0.0-rc.22
32+
* Support import with `{ type: "json" }` (#1202)
33+
* Support import with `{ type: "css" }` (#1193)
34+
* Support `.d.cts` types (#987)
35+
* Support namespace-based external marking (#1188)
36+
* Optimize storage (#1260)
37+
* Remove unsafe `x-zone-id` and `x-npmrc` headers (#1235)
38+
* Ban urls with `/../` segments in path (#1271)
39+
* Reserve semantic version of dependencies (#1313)
40+
* Cache npm registry "not found" responses (#1297)
41+
* Add `npmBackupRegistry` config for rate limitation (#1296)
42+
* Fix sub-modules end with `.map` (#1311)
43+
* Fix tree-shaking with exports query (#1310)
44+
* Fix memory leak (#1157)
45+
* Fix S3 Storage signature with `/#/` path (#1022)
46+
* Fix forward build deps for Typescript types (#1244)
47+
* Fix `pkg.pr.new` redirects (#1204)
48+
* Fix SSRF (#1149)
49+
* Fix `*.css?module` XSS (#1237)
50+
* Fix dts_lexer: bufio.Scanner: token too long (#1139)
51+
* Fix cjs-module-lexer timeout (#1265)
252

353
## v136
454

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM golang:1.25-alpine AS builder
1+
# build >>>
2+
FROM golang:1.26-alpine AS builder
23

34
ARG SERVER_VERSION="main"
45

@@ -7,16 +8,17 @@ RUN git clone --branch $SERVER_VERSION --depth 1 https://github.com/esm-dev/esm.
78

89
WORKDIR /tmp/esm.sh
910
RUN go build -ldflags="-s -w -X 'github.com/esm-dev/esm.sh/server.VERSION=${SERVER_VERSION}'" -o esmd server/esmd/main.go
11+
# <<< build
1012

1113
FROM alpine:latest
1214

1315
RUN apk update && apk add --no-cache git
1416
RUN addgroup -g 1000 esm && adduser -u 1000 --home=/esm -G esm -D esm
1517

1618
COPY --from=builder /tmp/esm.sh/esmd /bin/esmd
17-
COPY --from=denoland/deno:bin-2.5.6 --chown=esm:esm /deno /esm/bin/deno
19+
COPY --from=denoland/deno:bin-2.6.9 --chown=esm:esm /deno /esm/bin/deno
1820

19-
# deno desn't provider musl build yet, the hack below makes the gnu build working in alpine
21+
# deno doesn't provide musl build yet, the hack below makes the gnu build working in alpine
2022
# see https://github.com/denoland/deno_docker/blob/main/alpine.dockerfile
2123
COPY --from=gcr.io/distroless/cc --chown=root:root --chmod=755 /lib/*-linux-gnu/* /usr/local/lib/
2224
COPY --from=gcr.io/distroless/cc --chown=root:root --chmod=755 /lib/ld-linux-* /lib/

HOSTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ esm.sh provides a Docker image for fast deployment. You can pull the container i
6161

6262
```bash
6363
docker pull ghcr.io/esm-dev/esm.sh # latest stable version
64-
docker pull ghcr.io/esm-dev/esm.sh:v136_1 # specific stable version
64+
docker pull ghcr.io/esm-dev/esm.sh:v137 # specified stable version
6565
docker pull ghcr.io/esm-dev/esm.sh:dev # latest dev version
6666
```
6767

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ run/cli/tidy:
88
@go run -tags debug main.go tidy
99

1010
run/cli/dev:
11-
@go run -tags debug main.go dev ${args} cli/template/${app}
11+
@go run -tags debug main.go dev ${args} cli/templates/${app}
1212

1313
run/cli/serve:
14-
@go run -tags debug main.go serve ${args} cli/template/${app}
14+
@go run -tags debug main.go serve ${args} cli/templates/${app}
1515

1616
run/server: config.json
1717
@rm -rf .esmd/log

README.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -301,41 +301,6 @@ you to use query params with trailing slash: change the query prefix `?` to `&`
301301
}
302302
```
303303

304-
## Using `esm.sh/tsx`
305-
306-
`esm.sh/tsx` is a lightweight **1KB** script that allows you to write `TSX` directly in HTML without any build steps. Your source code is sent to the server, compiled, cached at the edge, and served to the browser as a JavaScript module.
307-
308-
`esm.sh/tsx` supports `<script>` tags with `type` set to `text/babel`, `text/jsx`, `text/ts`, or `text/tsx`.
309-
310-
In development mode (open the page on localhost), `esm.sh/tsx` uses [@esm.sh/tsx](https://github.com/esm-dev/tsx) to transform JSX syntax into JavaScript.
311-
312-
```html
313-
<!DOCTYPE html>
314-
<html>
315-
<head>
316-
<script type="importmap">
317-
{
318-
"imports": {
319-
"react": "https://esm.sh/react@19.2.0",
320-
"react-dom/client": "https://esm.sh/react-dom@19.2.0/client"
321-
}
322-
}
323-
</script>
324-
<script type="module" src="https://esm.sh/tsx"></script>
325-
</head>
326-
<body>
327-
<div id="root"></div>
328-
<script type="text/babel">
329-
import { createRoot } from "react-dom/client"
330-
createRoot(root).render(<h1>Hello, World!</h1>)
331-
</script>
332-
</body>
333-
</html>
334-
```
335-
336-
> [!TIP]
337-
> By default, esm.sh transforms your JSX syntax with `jsxImportSource` set to `react` or `preact` which is specified in the `importmap`. To use a custom JSX runtime, add `@jsxRuntime` specifier in the `importmap` script. For example, [solid-js](https://esm.sh/solid-js/jsx-runtime).
338-
339304
## Escape Hatch: Raw Source Files
340305

341306
By default, esm.sh transforms (and bundles if necessary) the JavaScript source code. However, 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.

cli/README.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
# esm.sh CLI
22

3-
> [!WARNING]
4-
> The `esm.sh` CLI is still in development. Use it at your own risk.
3+
A _no-build_ tool for modern web development. Features include:
54

6-
A _nobuild_ tool for modern web development.
5+
- Initialize a new no-build web app with esm.sh CDN
6+
- Serve web apps with esm.sh CDN, HMR, transforming TS/Vue/Svelte on the fly
7+
- Maintain the `importmap` script in index.html
78

89
## Installation
910

10-
You can install `esm.sh` CLI from source code:
11+
Install `esm.sh` CLI via curl:
12+
13+
```bash
14+
curl -fsSL https://esm.sh/install | bash
15+
```
16+
17+
To install `esm.sh` CLI from source code, you need to have [Go](https://go.dev/dl) installed.
1118

1219
```bash
1320
go install github.com/esm-dev/esm.sh
1421
```
1522

16-
You can also install `esm.sh` CLI via `npm`:
23+
Or install `esm.sh` CLI via `npm`:
1724

1825
```bash
1926
npm install -g esm.sh
2027
```
2128

22-
Or use `npx` without installation:
29+
Or use `npx esm.sh` without installation:
2330

2431
```bash
2532
npx esm.sh [command]
@@ -29,16 +36,16 @@ npx esm.sh [command]
2936

3037
```
3138
$ esm.sh --help
32-
Usage: esm.sh [command] <options>
39+
Usage: esm.sh [command] [options]
3340
3441
Commands:
35-
add, i [...packages] Add specified packages to the "importmap" script in index.html
36-
update Update existing packages in the "importmap" script in index.html
37-
tidy Clean up and optimize the "importmap" script in index.html
38-
init Initialize a new web application
39-
serve Serve the web application in production mode
40-
dev Serve the web application in development mode with live reload
42+
add [...imports] Add imports to the "importmap" script in index.html
43+
tidy Clean up and optimize the "importmap" script in index.html
44+
init Initialize a new no-build web app
45+
serve Serve the web app in "production" mode
46+
dev Serve the web app in "development" mode with live reload
4147
4248
Options:
43-
--help Display this help message
49+
--version, -v Show the version
50+
--help, -h Display this help message
4451
```

cli/cli.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import (
55
"os"
66
)
77

8-
const helpMessage = "\033[30mesm.sh - A nobuild tool for modern web development.\033[0m" + `
8+
const helpMessage = "\033[30mesm.sh - A no-build tool for modern web development.\033[0m" + `
99
1010
Usage: esm.sh [command] [options]
1111
1212
Commands:
13-
add [...packages] Add specified packages to the "importmap" in index.html
14-
tidy Clean up and optimize the "importmap" in index.html
15-
init Initialize a new nobuild web app
13+
add [...imports] Add imports to the "importmap" script in index.html
14+
tidy Clean up and optimize the "importmap" script in index.html
15+
init Initialize a new no-build web app
1616
serve Serve the web app in "production" mode
1717
dev Serve the web app in "development" mode with live reload
1818
@@ -34,9 +34,9 @@ func Run() {
3434
case "init":
3535
Init()
3636
case "serve":
37-
Serve(false)
37+
Serve()
3838
case "dev":
39-
Serve(true)
39+
Dev()
4040
case "version":
4141
fmt.Println("esm.sh CLI " + VERSION)
4242
default:

cli/add.go renamed to cli/command_add.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ func (ui *subModuleSelectUI) clearLines() {
452452
term.ClearLine()
453453
os.Stdout.Write(EOL) // move to the next line
454454
}
455+
term.ClearLine()
455456
term.MoveCursorUp(height)
456457
}()
457458
}

cli/command_dev.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package cli
2+
3+
// Dev serves a web app in development mode.
4+
func Dev() {
5+
serve(true)
6+
}

0 commit comments

Comments
 (0)