-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathesm_sh.saas.txt
135 lines (94 loc) · 6.49 KB
/
esm_sh.saas.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
┏━━━━━━━━━━━━┓
┃ ESM_SH ┃
┗━━━━━━━━━━━━┛
ALTERNATIVES ==> #See JSR
VERSION ==> #v135_7
INFRASTRUCTURE ==> #Cloudflare CDN
#Can be self-hosted
GOAL ==> #CDN serving npm modules or GitHub packages
#Can bundle with esbuild (including tree-shaking)
#Has good support for Deno, WASM, CSS-in-JS
┌──────────┐
│ MAIN │
└──────────┘
https://esm.sh/MODULE[/PATH] #Return file contents
#If JavaScript (not TypeScript), bundled with esbuild
# - use a first file which points to the bundled esm.sh URL,
# to keep response small in case source code is loaded lazily
MODULE #Either:
# - NPM_MODULE[@VERSION_RANGE|NPM_TAG]
# - def TAG: latest
# - gh/USER/REPO[@GIT_TAG]
?... #Can be before the ending slash in IMPORT_MAP, i.e. IMPORT_MAP.imports.NAME '...?.../'
┌────────────┐
│ BUNDLE │
└────────────┘
?bundle-deps #Bundles all dependencies from package.json
?no-bundle #Inverse
PACKAGE['esm.sh'].bundle #BOOL (def: true)
#Whether esm.sh should bundle this dependency
?exports=VAR,... #Only include specific exports. Does tree-shaking
?cjs-exports=VAR,... #Specify CommonJS exports, when they cannot be guessed statistically
?deps=NPM_MODULE[@...],... #Overwrite package.json dependencies
?external=IURL,... #Add dependencies specified in IMPORT_MAP.imports.IURL
#NAME can be *
?alias=IURL:OURL #Maps IURL similar to an IMPORT_MAP
?dev #Set NODE_ENV to 'development'
#Use package.json CONDITION 'development', i.e. exports.development
?conditions=CONDITION,... #
?raw #Do not transform source file, keep as is
┌──────────┐
│ MISC │
└──────────┘
?keep-names #Keep FUNC.name instead of minifying
?ignore-annotations #Ignore package.json sideEffects field
?worker #Returns as FUNC(['CODE'])->WORKER
#WORKER loads the code. Can add additional 'CODE'
?wasm #When importing *.wasm, wrap in new WebAssembly.Module('WASM_CODE')
?css #When imports CSS in JavaScript
?pin=ESM_SH_VERSION #Set esm.sh version, to pin it and prevent changes
┌──────────┐
│ DENO │
└──────────┘
?target=TARGET #Among esYYYY, esnext, deno[next]
#Def: guessed based on User-Agent [C]
NODE SHIMS ==> #Used when using Deno, use Node shims like Deno does on Node imports
?deno-std=X.Y.Z #Deno std used (def: latest)
?no-dts #Unless specified, if target is Deno, send package.json `types` as X-TypeScript-Types [S]
┌─────────┐
│ CLI │
└─────────┘
deno run -A https://esm.sh COMMAND#CLI to add esm.sh URLs to an IMPORT_MAP
.../esm.sh init #Creates:
# - an empty import_map.json
# - a deno.json with tasks esm:add|update|remote calling .../esm.sh add|update|remove
.../esm.sh add MODULE[@...]... #Add to IMPORT_MAP:
# - imports.IURL[/] 'https://esm.sh/MODULE@...[/]', for package itself
# - scopes['https://esm.sh/'].DEP_MODULE 'https://esm.sh/DEP_MODULE@...', for dependencies
.../esm.sh update MODULE... #
.../esm.sh remove MODULE... #
┌───────────────┐
│ TRANSPILE │
└───────────────┘
https://esm.sh/run #No exports (use side effects instead)
#Transpile <script> HTML tags in current page with following types:
# - text/babel: TypeScript + JSX|TSX
# - text/ts: TypeScript
# - text/jsx|tsx
#Also polyfills <script type="importmap"> for older browsers
#Max 64KB per <script>, max 60 requests/min, i.e. dev only
┌─────────┐
│ API │
└─────────┘
PROGRAMMATIC API ==> #Available. Not documented yet
┌───────────┐
│ LOCAL │
└───────────┘
import
('https://esm.sh/vVERSION/server')#Exports `serve`
serve(FUNC(REQ)) #Run esm.sh server programmatically
deno run -A https://esm.sh/server #CLI
┌────────┐
│ UI │
└────────┘
PLAYGROUND ==> #Code editor, with esm.sh bundle shown on the right