@yaks/esbuild 0.0.0-stage → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +450 -2
- package/_dist/bundle.d.ts +6 -0
- package/_dist/bundle.d.ts.map +1 -0
- package/_dist/compile.d.ts +72 -0
- package/_dist/compile.d.ts.map +1 -0
- package/_dist/dependencies.d.ts +15 -0
- package/_dist/dependencies.d.ts.map +1 -0
- package/_dist/file.d.ts +185 -0
- package/_dist/file.d.ts.map +1 -0
- package/_dist/graph.d.ts +104 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/home.d.ts +15 -0
- package/_dist/home.d.ts.map +1 -0
- package/_dist/link.d.ts +192 -0
- package/_dist/link.d.ts.map +1 -0
- package/_dist/lock.d.ts +30 -0
- package/_dist/lock.d.ts.map +1 -0
- package/_dist/mod.d.ts +6 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/pack.d.ts +42 -0
- package/_dist/pack.d.ts.map +1 -0
- package/_dist/package.d.ts +11 -0
- package/_dist/package.d.ts.map +1 -0
- package/_dist/plan.d.ts +135 -0
- package/_dist/plan.d.ts.map +1 -0
- package/_dist/platform.d.ts +27 -0
- package/_dist/platform.d.ts.map +1 -0
- package/_dist/resolve.d.ts +42 -0
- package/_dist/resolve.d.ts.map +1 -0
- package/_dist/shelf.d.ts +11 -0
- package/_dist/shelf.d.ts.map +1 -0
- package/_dist/strip.d.ts +51 -0
- package/_dist/strip.d.ts.map +1 -0
- package/_dist/timing.d.ts +6 -0
- package/_dist/timing.d.ts.map +1 -0
- package/_dist/unpack.d.ts +14 -0
- package/_dist/unpack.d.ts.map +1 -0
- package/analysis.js +72 -0
- package/analysis.js.map +1 -0
- package/analysis.ts +82 -0
- package/bundle.js +320 -0
- package/bundle.js.map +1 -0
- package/bundle.ts +415 -0
- package/common.js +129 -0
- package/common.js.map +1 -0
- package/common.ts +138 -0
- package/compile.js +500 -0
- package/compile.js.map +1 -0
- package/compile.ts +622 -0
- package/container.js +142 -0
- package/container.js.map +1 -0
- package/container.ts +183 -0
- package/deno.json +1 -0
- package/dependencies.js +31 -0
- package/dependencies.js.map +1 -0
- package/dependencies.ts +40 -0
- package/file.js +303 -0
- package/file.js.map +1 -0
- package/file.ts +443 -0
- package/forward.ts +49 -0
- package/graph.js +297 -0
- package/graph.js.map +1 -0
- package/graph.ts +360 -0
- package/home.js +40 -0
- package/home.js.map +1 -0
- package/home.ts +52 -0
- package/link.js +455 -0
- package/link.js.map +1 -0
- package/link.ts +596 -0
- package/lock.js +129 -0
- package/lock.js.map +1 -0
- package/lock.ts +161 -0
- package/mod.js +14 -0
- package/mod.js.map +1 -0
- package/mod.ts +43 -0
- package/npm.js +362 -0
- package/npm.js.map +1 -0
- package/npm.ts +429 -0
- package/pack.js +188 -0
- package/pack.js.map +1 -0
- package/pack.ts +225 -0
- package/package.js +199 -0
- package/package.js.map +1 -0
- package/package.json +60 -4
- package/package.ts +255 -0
- package/plan.js +273 -0
- package/plan.js.map +1 -0
- package/plan.ts +395 -0
- package/platform.js +160 -0
- package/platform.js.map +1 -0
- package/platform.ts +238 -0
- package/resolve.js +86 -0
- package/resolve.js.map +1 -0
- package/resolve.ts +144 -0
- package/said.js +44 -0
- package/said.js.map +1 -0
- package/said.ts +61 -0
- package/serve.ts +37 -0
- package/sha256.js +7 -0
- package/sha256.js.map +1 -0
- package/sha256.ts +10 -0
- package/shared.js +646 -0
- package/shared.js.map +1 -0
- package/shared.ts +813 -0
- package/shelf.js +73 -0
- package/shelf.js.map +1 -0
- package/shelf.ts +110 -0
- package/strip.js +114 -0
- package/strip.js.map +1 -0
- package/strip.ts +117 -0
- package/tar.js +87 -0
- package/tar.js.map +1 -0
- package/tar.ts +99 -0
- package/timing.js +37 -0
- package/timing.js.map +1 -0
- package/timing.ts +71 -0
- package/unpack.js +40 -0
- package/unpack.js.map +1 -0
- package/unpack.ts +60 -0
- package/used.js +91 -0
- package/used.js.map +1 -0
- package/used.ts +116 -0
package/plan.ts
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
// What a deploy must compile, read out of an app's files, or nothing.
|
|
2
|
+
//
|
|
3
|
+
// Two kinds of entry. The worker is the app's server source (the host says
|
|
4
|
+
// which file that is), compiled when a file it reaches is TypeScript or JSX,
|
|
5
|
+
// or when it imports a package: the runtime has no registry, so a package it
|
|
6
|
+
// imports is either compiled in or missing. A page script is each
|
|
7
|
+
// `<script type="module" src>` an HTML file loads, compiled when a file it
|
|
8
|
+
// reaches is TypeScript or JSX, or when it imports a package package.json
|
|
9
|
+
// names. A package package.json does not name is left to the browser, which
|
|
10
|
+
// resolves it through the page's import map; the deploy says so when the map
|
|
11
|
+
// does not name it. A module worker a page script starts (`new Worker(new
|
|
12
|
+
// URL('./grow.ts', import.meta.url))`) is a page script too, compiled by the
|
|
13
|
+
// same rule, except that no import map reaches it.
|
|
14
|
+
//
|
|
15
|
+
// File-only apps with no TypeScript or package.json plan nothing. A JavaScript
|
|
16
|
+
// worker can also ask the compiler to embed a text import.
|
|
17
|
+
import type { Catalog } from './platform.ts'
|
|
18
|
+
import type { Timing } from './timing.ts'
|
|
19
|
+
import {
|
|
20
|
+
packageOf,
|
|
21
|
+
type Reached,
|
|
22
|
+
type Read,
|
|
23
|
+
resolved,
|
|
24
|
+
script,
|
|
25
|
+
sources,
|
|
26
|
+
type Strip,
|
|
27
|
+
typed,
|
|
28
|
+
} from './graph.js'
|
|
29
|
+
import { dependencies, Unplanned } from './dependencies.js'
|
|
30
|
+
|
|
31
|
+
export { dependencies, Unplanned }
|
|
32
|
+
|
|
33
|
+
/** An app's files, as the host holds them. */
|
|
34
|
+
export type App = {
|
|
35
|
+
/** Every file the app wrote, by its path from the app's root. */
|
|
36
|
+
paths: string[]
|
|
37
|
+
read: Read
|
|
38
|
+
/** The server source, when the app has one. */
|
|
39
|
+
main?: string
|
|
40
|
+
/** Compile just this server entry, including one with no imports. */
|
|
41
|
+
entryOnly?: boolean
|
|
42
|
+
/** Its compatibility flags (`nodejs_compat` changes how it compiles). */
|
|
43
|
+
flags?: string[]
|
|
44
|
+
/** The folder its pages are served from, when not its root (a build's
|
|
45
|
+
* `dist`): only HTML inside it is a page whose scripts are compiled. */
|
|
46
|
+
served?: string
|
|
47
|
+
/** How its TypeScript and JSX are read as JavaScript (`./strip`), asked
|
|
48
|
+
* only of an app that has some. */
|
|
49
|
+
strip: Strip
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** What the compiler is handed: the text of every file a build reads, and
|
|
53
|
+
* which entries to build. */
|
|
54
|
+
export type Ask = {
|
|
55
|
+
files: Record<string, string>
|
|
56
|
+
worker?: {
|
|
57
|
+
entry: string
|
|
58
|
+
flags: string[]
|
|
59
|
+
/** What it imports that is not compiled in (a `.wasm`, a `.txt`): the
|
|
60
|
+
* host uploads each beside the compiled module, by its own path. */
|
|
61
|
+
carry: string[]
|
|
62
|
+
}
|
|
63
|
+
/** The page scripts to compile, and the module workers they start. */
|
|
64
|
+
pages: string[]
|
|
65
|
+
/** The pages one HTML page loads together, where it loads two or more:
|
|
66
|
+
* they share one pack of shared modules (./shared.ts `pack`). */
|
|
67
|
+
together?: string[][]
|
|
68
|
+
/** The package imports of each page script that package.json does not
|
|
69
|
+
* name and the import map of every page loading it resolves: the
|
|
70
|
+
* browser's to load, left as written. */
|
|
71
|
+
mapped?: Record<string, string[]>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** What the compiler answers. Any `errors` mean nothing it made may be used;
|
|
75
|
+
* each is a line an agent can act on. */
|
|
76
|
+
export type Answer = {
|
|
77
|
+
/** Compiler wall-clock milliseconds, when timing was requested. */
|
|
78
|
+
timing?: Timing
|
|
79
|
+
/** The compiled worker: one ES module, uploaded under `main`. */
|
|
80
|
+
worker?: { main: string; code: string }
|
|
81
|
+
/** Each compiled page script, by the entry's own path. */
|
|
82
|
+
pages: Record<string, string>
|
|
83
|
+
/** Runtime package resources, under a reserved package-relative namespace. */
|
|
84
|
+
assets: Record<string, string>
|
|
85
|
+
/** Content-addressed browser modules and resources, shared across apps. */
|
|
86
|
+
shared?: Record<string, string>
|
|
87
|
+
/** The registry tarball that fills each npm package home the compiled code
|
|
88
|
+
* names, by the SHA-256 that names the home (./home.ts). */
|
|
89
|
+
tarballs?: Record<string, string>
|
|
90
|
+
/** package-lock.json as the build left it, when the app has a package.json. */
|
|
91
|
+
lock?: string
|
|
92
|
+
/** What the lock holds, as `name@version`. */
|
|
93
|
+
installed: string[]
|
|
94
|
+
notes: string[]
|
|
95
|
+
errors: string[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The plan: what to ask, what to say, and each entry's own source paths. */
|
|
99
|
+
export type Plan = {
|
|
100
|
+
ask: Ask
|
|
101
|
+
notes: string[]
|
|
102
|
+
inputs: { worker?: string[]; pages: Record<string, string[]> }
|
|
103
|
+
/** Every existing source read to decide this plan, including plain JS. */
|
|
104
|
+
reads: string[]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// What esbuild reads as source. Anything else a worker imports is a module of
|
|
108
|
+
// its own kind (`.wasm`, `.txt`, bytes) that the runtime links as it is.
|
|
109
|
+
let COMPILED = /\.(?:js|mjs|cjs|ts|tsx|jsx|mts|cts|json|css)$/
|
|
110
|
+
|
|
111
|
+
let decode = (bytes: Uint8Array) => new TextDecoder().decode(bytes)
|
|
112
|
+
|
|
113
|
+
/** Each toolkit package of a catalog: its source digest, and the toolkit
|
|
114
|
+
* packages it depends on. A host keeps this beside the catalog, small enough
|
|
115
|
+
* to read wherever it asks whether a compile's toolkit is still current. */
|
|
116
|
+
export type Toolkits = Record<string, { version: string; uses: string[] }>
|
|
117
|
+
|
|
118
|
+
/** A catalog's {@link Toolkits}.
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { assertEquals } from '@std/assert'
|
|
122
|
+
* assertEquals(
|
|
123
|
+
* toolkits({
|
|
124
|
+
* '@yaks/a': {
|
|
125
|
+
* files: {},
|
|
126
|
+
* dependencies: { '@yaks/b': 'platform', preact: '10.29.7' },
|
|
127
|
+
* version: 'sha256:a',
|
|
128
|
+
* },
|
|
129
|
+
* }),
|
|
130
|
+
* { '@yaks/a': { version: 'sha256:a', uses: ['@yaks/b'] } },
|
|
131
|
+
* )
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export let toolkits = (catalog: Catalog): Toolkits =>
|
|
135
|
+
Object.fromEntries(
|
|
136
|
+
Object.entries(catalog).map(([name, pkg]) => [name, {
|
|
137
|
+
version: pkg.version,
|
|
138
|
+
uses: Object.keys(pkg.dependencies).filter((dep) =>
|
|
139
|
+
dep.startsWith('@yaks/')
|
|
140
|
+
),
|
|
141
|
+
}]),
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
/** The compiler's own entry among the toolkit's digests, where a host keeps
|
|
145
|
+
* one: the source of this package, which makes what pages compile to, as a
|
|
146
|
+
* toolkit package's source makes what they import. */
|
|
147
|
+
export let COMPILER: string = '@yaks/esbuild'
|
|
148
|
+
|
|
149
|
+
/** The source digest of each toolkit package a package.json reaches, through
|
|
150
|
+
* the toolkit's own dependencies, as a compile seeds them, and of the
|
|
151
|
+
* compiler: what that compile was made of. A package the toolkit does not
|
|
152
|
+
* have is left out.
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { assertEquals } from '@std/assert'
|
|
156
|
+
* let kit = {
|
|
157
|
+
* '@yaks/a': { version: 'sha256:a', uses: ['@yaks/b'] },
|
|
158
|
+
* '@yaks/b': { version: 'sha256:b', uses: [] },
|
|
159
|
+
* '@yaks/c': { version: 'sha256:c', uses: [] },
|
|
160
|
+
* }
|
|
161
|
+
* let pkg = '{"dependencies": {"@yaks/a": "platform", "three": "1"}}'
|
|
162
|
+
* assertEquals(toolkitOf(pkg, kit), {
|
|
163
|
+
* '@yaks/a': 'sha256:a',
|
|
164
|
+
* '@yaks/b': 'sha256:b',
|
|
165
|
+
* })
|
|
166
|
+
* assertEquals(toolkitOf(null, kit), {})
|
|
167
|
+
* assertEquals(
|
|
168
|
+
* toolkitOf(null, { '@yaks/esbuild': { version: 'sha256:e', uses: [] } }),
|
|
169
|
+
* { '@yaks/esbuild': 'sha256:e' },
|
|
170
|
+
* )
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export let toolkitOf = (
|
|
174
|
+
pkg: string | null,
|
|
175
|
+
kit: Toolkits,
|
|
176
|
+
): Record<string, string> => {
|
|
177
|
+
let out: Record<string, string> = kit[COMPILER]
|
|
178
|
+
? { [COMPILER]: kit[COMPILER].version }
|
|
179
|
+
: {}
|
|
180
|
+
let visit = (name: string) => {
|
|
181
|
+
if (name in out || !kit[name]) return
|
|
182
|
+
out[name] = kit[name].version
|
|
183
|
+
kit[name].uses.forEach(visit)
|
|
184
|
+
}
|
|
185
|
+
Object.keys(dependencies(pkg)).forEach(visit)
|
|
186
|
+
return out
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let TAG = /<script\b[^>]*>/gi
|
|
190
|
+
let SRC = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/i
|
|
191
|
+
let MODULE = /\btype\s*=\s*(?:"module"|'module'|module\b)/i
|
|
192
|
+
|
|
193
|
+
/** The module scripts an HTML file loads from the app's own files, by path.
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* import { assertEquals } from '@std/assert'
|
|
197
|
+
* assertEquals(
|
|
198
|
+
* loaded('games/index.html', `<script type="module" src="./main.ts?v=2">` +
|
|
199
|
+
* `</script><script src="old.js"></script>` +
|
|
200
|
+
* `<script type=module src="https://esm.sh/x"></script>`),
|
|
201
|
+
* ['games/main.ts'],
|
|
202
|
+
* )
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
export let loaded = (page: string, html: string): string[] =>
|
|
206
|
+
[...html.matchAll(TAG)]
|
|
207
|
+
.filter(([tag]) => MODULE.test(tag))
|
|
208
|
+
.map(([tag]) => tag.match(SRC))
|
|
209
|
+
.map((m) => m && (m[1] ?? m[2] ?? m[3]).replace(/[?#].*$/, ''))
|
|
210
|
+
.filter((src): src is string =>
|
|
211
|
+
!!src && !src.startsWith('/') && !/^[a-z][a-z0-9+.-]*:/i.test(src)
|
|
212
|
+
)
|
|
213
|
+
.map((src) => resolved(page, src.startsWith('.') ? src : `./${src}`))
|
|
214
|
+
|
|
215
|
+
let MAP =
|
|
216
|
+
/<script\b[^>]*\btype\s*=\s*(?:"importmap"|'importmap'|importmap\b)[^>]*>([\s\S]*?)<\/script/gi
|
|
217
|
+
|
|
218
|
+
// The keys of an import map's `imports`; none when it is not JSON, which the
|
|
219
|
+
// browser refuses too.
|
|
220
|
+
let keys = (json: string): string[] => {
|
|
221
|
+
try {
|
|
222
|
+
let imports = JSON.parse(json)?.imports
|
|
223
|
+
return imports && typeof imports == 'object' ? Object.keys(imports) : []
|
|
224
|
+
} catch {
|
|
225
|
+
return []
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** What an HTML file's import maps name: every key of their `imports`.
|
|
230
|
+
*
|
|
231
|
+
* ```ts
|
|
232
|
+
* import { assertEquals } from '@std/assert'
|
|
233
|
+
* assertEquals(
|
|
234
|
+
* mapped(`<script type=importmap>{"imports": {"three": "https://esm.sh/` +
|
|
235
|
+
* `three", "lit/": "https://esm.sh/lit/"}}</script>`),
|
|
236
|
+
* ['three', 'lit/'],
|
|
237
|
+
* )
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export let mapped = (html: string): string[] =>
|
|
241
|
+
[...html.matchAll(MAP)].flatMap(([, json]) => keys(json))
|
|
242
|
+
|
|
243
|
+
// Whether an import map's keys resolve a specifier: a key names it, or ends
|
|
244
|
+
// in `/` and begins it.
|
|
245
|
+
let covers = (map: string[], spec: string) =>
|
|
246
|
+
map.some((key) => key == spec || key.endsWith('/') && spec.startsWith(key))
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* What a deploy of this app compiles, or null when nothing needs compiling.
|
|
250
|
+
* Throws {@link Unplanned} when package.json cannot be read.
|
|
251
|
+
*/
|
|
252
|
+
export let plan = async (app: App): Promise<Plan | null> => {
|
|
253
|
+
let main = app.main && app.paths.includes(app.main) ? app.main : undefined
|
|
254
|
+
// Skip file-only apps that have no inputs to the compiler.
|
|
255
|
+
if (!main && !app.paths.includes('package.json') && !app.paths.some(typed)) {
|
|
256
|
+
return null
|
|
257
|
+
}
|
|
258
|
+
let has = new Set(app.paths)
|
|
259
|
+
// The worker and each page walk their own graph, often through the same
|
|
260
|
+
// modules. Keep one reading of each file for this deploy.
|
|
261
|
+
let reads = new Map<string, ReturnType<Read>>()
|
|
262
|
+
let readApp: Read = (path) => {
|
|
263
|
+
if (!has.has(path)) return Promise.resolve(null)
|
|
264
|
+
let pending = reads.get(path)
|
|
265
|
+
if (pending) return pending
|
|
266
|
+
pending = app.read(path)
|
|
267
|
+
reads.set(path, pending)
|
|
268
|
+
return pending
|
|
269
|
+
}
|
|
270
|
+
let text = async (path: string) => {
|
|
271
|
+
let bytes = await readApp(path)
|
|
272
|
+
return bytes && decode(bytes)
|
|
273
|
+
}
|
|
274
|
+
let pkg = await text('package.json')
|
|
275
|
+
let named = new Set(Object.keys(dependencies(pkg)))
|
|
276
|
+
let files: Record<string, string> = {}
|
|
277
|
+
let notes: string[] = []
|
|
278
|
+
let inputs: Plan['inputs'] = { pages: {} }
|
|
279
|
+
let send = ({ files: reached, texts }: Reached) => {
|
|
280
|
+
let paths = [...reached.keys()].filter((p) =>
|
|
281
|
+
COMPILED.test(p) || texts.has(p)
|
|
282
|
+
)
|
|
283
|
+
for (let path of paths) files[path] = decode(reached.get(path)!)
|
|
284
|
+
return paths
|
|
285
|
+
}
|
|
286
|
+
let walk = sources(app.strip)
|
|
287
|
+
let worker: Ask['worker']
|
|
288
|
+
if (main) {
|
|
289
|
+
let graph = await walk(readApp, main)
|
|
290
|
+
let { files: reached, named: specs, texts, linked } = graph
|
|
291
|
+
let packages = specs.filter((s) => packageOf(s))
|
|
292
|
+
if (
|
|
293
|
+
app.entryOnly || [...reached.keys()].some(typed) || packages.length ||
|
|
294
|
+
texts.size
|
|
295
|
+
) {
|
|
296
|
+
inputs.worker = send(graph)
|
|
297
|
+
worker = {
|
|
298
|
+
entry: main,
|
|
299
|
+
flags: app.flags ?? [],
|
|
300
|
+
carry: [...reached.keys()].filter((p) =>
|
|
301
|
+
!COMPILED.test(p) && (!texts.has(p) || linked.has(p))
|
|
302
|
+
),
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Each module script the pages load, with the import map of every page
|
|
308
|
+
// that loads it. A worker a script starts joins as the walk finds it, with
|
|
309
|
+
// no import map at all, since none reaches a worker.
|
|
310
|
+
let loads = new Map<string, string[][]>()
|
|
311
|
+
let started = new Set<string>()
|
|
312
|
+
let served = app.served ? `${app.served}/` : ''
|
|
313
|
+
let pagesOf = app.entryOnly
|
|
314
|
+
? []
|
|
315
|
+
: app.paths.filter((p) => /\.html?$/i.test(p) && p.startsWith(served))
|
|
316
|
+
let documents: string[][] = []
|
|
317
|
+
let left: Record<string, string[]> = {}
|
|
318
|
+
for (let page of pagesOf) {
|
|
319
|
+
let html = await text(page) ?? ''
|
|
320
|
+
let entries = loaded(page, html)
|
|
321
|
+
documents.push(entries)
|
|
322
|
+
for (let entry of entries) {
|
|
323
|
+
loads.set(entry, [...loads.get(entry) ?? [], mapped(html)])
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
let pages: string[] = []
|
|
327
|
+
for (let [entry, maps] of loads) {
|
|
328
|
+
if (!has.has(entry) || !script(entry)) continue
|
|
329
|
+
let graph = await walk(readApp, entry)
|
|
330
|
+
let { files: reached, named: specs, started: starts, texts } = graph
|
|
331
|
+
let wanted = specs.filter((s) => named.has(packageOf(s) ?? ''))
|
|
332
|
+
let compiled = [...reached.keys()].some(typed) || wanted.length > 0 ||
|
|
333
|
+
texts.size > 0
|
|
334
|
+
// esbuild leaves `import.meta.url` as written, so in a compiled script
|
|
335
|
+
// it is the entry's address, and a worker's path resolves against the
|
|
336
|
+
// entry; in a script served as written, against the file that names it.
|
|
337
|
+
for (let [from, spec] of starts) {
|
|
338
|
+
let path = resolved(compiled ? entry : from, spec)
|
|
339
|
+
if (loads.has(path)) continue
|
|
340
|
+
started.add(path)
|
|
341
|
+
loads.set(path, [[]])
|
|
342
|
+
}
|
|
343
|
+
if (!compiled) continue
|
|
344
|
+
pages.push(entry)
|
|
345
|
+
inputs.pages[entry] = send(graph)
|
|
346
|
+
// A package the compile leaves in is the browser's to resolve, and only
|
|
347
|
+
// an import map on every page that loads the script resolves it.
|
|
348
|
+
for (let spec of new Set(specs)) {
|
|
349
|
+
let name = packageOf(spec)
|
|
350
|
+
if (!name || named.has(name)) continue
|
|
351
|
+
if (maps.every((m) => covers(m, spec))) {
|
|
352
|
+
;(left[entry] ??= []).push(spec)
|
|
353
|
+
continue
|
|
354
|
+
}
|
|
355
|
+
notes.push(
|
|
356
|
+
`${entry} imports ${spec}, which ` +
|
|
357
|
+
(started.has(entry)
|
|
358
|
+
? 'package.json does not name, and no import map reaches a ' +
|
|
359
|
+
'module worker, so the browser cannot load it'
|
|
360
|
+
: "neither package.json nor the page's import map names, so the " +
|
|
361
|
+
'browser cannot load it'),
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
for (
|
|
365
|
+
let css of [...reached.keys()].filter((p) =>
|
|
366
|
+
p.endsWith('.css') && !texts.has(p)
|
|
367
|
+
)
|
|
368
|
+
) {
|
|
369
|
+
notes.push(
|
|
370
|
+
`${entry} imports ${css}, and a compiled page script leaves CSS ` +
|
|
371
|
+
`out: link it from the page instead`,
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (!worker && !pages.length) return null
|
|
377
|
+
if (pkg != null) files['package.json'] = pkg
|
|
378
|
+
let lock = await text('package-lock.json')
|
|
379
|
+
if (lock != null) files['package-lock.json'] = lock
|
|
380
|
+
let together = documents
|
|
381
|
+
.map((entries) => [...new Set(entries.filter((e) => pages.includes(e)))])
|
|
382
|
+
.filter((entries) => entries.length > 1)
|
|
383
|
+
return {
|
|
384
|
+
ask: {
|
|
385
|
+
files,
|
|
386
|
+
worker,
|
|
387
|
+
pages,
|
|
388
|
+
...together.length ? { together } : {},
|
|
389
|
+
...Object.keys(left).length ? { mapped: left } : {},
|
|
390
|
+
},
|
|
391
|
+
notes,
|
|
392
|
+
inputs,
|
|
393
|
+
reads: [...reads.keys()],
|
|
394
|
+
}
|
|
395
|
+
}
|
package/platform.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// @ts-types="@types/semver"
|
|
2
|
+
// Compiler-owned toolkit sources, seeded as npm-shaped packages. Only declared
|
|
3
|
+
// toolkit roots and their catalog dependency closure enter a build; their source
|
|
4
|
+
// digests describe what was compiled, never a version to ask the registry for.
|
|
5
|
+
/* @ts-types="npm:@types/semver@^7.8.0" */ import { gt, intersects, minVersion, Range } from "semver";
|
|
6
|
+
import { parse } from "es-module-lexer/js";
|
|
7
|
+
import { packageOf, script } from "./graph.js";
|
|
8
|
+
import { dependencies } from "./plan.js";
|
|
9
|
+
/** The package supplying an import after the app's renderer is selected. */ export let packageFor = (setup, spec)=>packageOf(setup.aliases?.[spec] ?? spec) ?? undefined;
|
|
10
|
+
/** Runtime resources stay outside the app's own paths. */ export let ASSETS = '__packages/';
|
|
11
|
+
let toolkit = (name)=>name.startsWith('@yaks/');
|
|
12
|
+
let safe = (path)=>!!path && !path.startsWith('/') && !path.split('/').some((p)=>!p || p == '.' || p == '..') && !/[\\?#%]/.test(path);
|
|
13
|
+
// The lexer identifies import.meta outside comments, strings and regexps.
|
|
14
|
+
let urlProp = /^(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*(?:\n|$))*\.(?:\s|\/\*[\s\S]*?\*\/)*url\b/;
|
|
15
|
+
/** Preserve a package module's URL when its source is bundled into an entry.
|
|
16
|
+
* Page paths resolve against the browser's entry URL. A server entry supplies
|
|
17
|
+
* its absolute logical module URL, since workerd names modules without an origin. */ export let located = (files, entry, baseFor)=>{
|
|
18
|
+
let out = {};
|
|
19
|
+
let path = typeof entry == 'string' ? entry : entry.pathname.slice(1);
|
|
20
|
+
let up = '../'.repeat(path.split('/').length - 1);
|
|
21
|
+
for (let [path, source] of Object.entries(files)){
|
|
22
|
+
if (!path.startsWith('node_modules/@yaks/') || !script(path)) continue;
|
|
23
|
+
let base = baseFor?.(path) ?? up + ASSETS + path.slice('node_modules/'.length);
|
|
24
|
+
out[path] = moved(source, ()=>typeof entry == 'string' ? urlOf(base) : JSON.stringify(new URL(base, entry).href));
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
/** The expression for `base`, a path from the module that is running. */ export let urlOf = (base)=>`new URL(${JSON.stringify(base)}, import.meta.url).href`;
|
|
29
|
+
/** A module's source with each `import.meta.url` read replaced by `value()`,
|
|
30
|
+
* an expression for the address the module is served from. `value` is asked
|
|
31
|
+
* only of a module that reads its URL, and none leaves the module as it is. */ export let moved = (source, value)=>{
|
|
32
|
+
let to;
|
|
33
|
+
for (let imp of parse(source)[0].toReversed()){
|
|
34
|
+
if (imp.d != -2) continue;
|
|
35
|
+
let tail = urlProp.exec(source.slice(imp.e));
|
|
36
|
+
if (!tail) continue;
|
|
37
|
+
to ??= value();
|
|
38
|
+
if (to == null) return source;
|
|
39
|
+
source = source.slice(0, imp.s) + to + source.slice(imp.e + tail[0].length);
|
|
40
|
+
}
|
|
41
|
+
return source;
|
|
42
|
+
};
|
|
43
|
+
// The lowest version a range allows, or null for a tag or a URL.
|
|
44
|
+
let least = (range)=>{
|
|
45
|
+
try {
|
|
46
|
+
return minVersion(range)?.version ?? null;
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** One version for a flat install that two consumers ask for: what both
|
|
52
|
+
* ranges allow, else the higher of two that semver calls compatible, as when
|
|
53
|
+
* a release pins the marked its toolkit used before the toolkit moved on.
|
|
54
|
+
* `noted` hears that choice; different majors cannot share one install. */ export let together = (name, a, b, noted = ()=>{})=>{
|
|
55
|
+
if (a == b) return a;
|
|
56
|
+
try {
|
|
57
|
+
if (intersects(a, b)) {
|
|
58
|
+
let choices = new Range(a).set.flatMap((left)=>new Range(b).set.map((right)=>[
|
|
59
|
+
...left,
|
|
60
|
+
...right
|
|
61
|
+
].map((c)=>c.value).filter(Boolean).join(' ')));
|
|
62
|
+
return choices.join(' || ');
|
|
63
|
+
}
|
|
64
|
+
let [low, high] = [
|
|
65
|
+
least(a),
|
|
66
|
+
least(b)
|
|
67
|
+
];
|
|
68
|
+
if (low && high && intersects(`^${low}`, `^${high}`)) {
|
|
69
|
+
let [kept, left] = gt(low, high) ? [
|
|
70
|
+
a,
|
|
71
|
+
b
|
|
72
|
+
] : [
|
|
73
|
+
b,
|
|
74
|
+
a
|
|
75
|
+
];
|
|
76
|
+
noted(`package.json: ${name} ${left} and ${kept} are both asked for; ` + `the one install is ${kept}`);
|
|
77
|
+
return kept;
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// Different tags and URLs cannot express a shared version constraint.
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`package.json: ${name} has incompatible versions ${a} and ${b}`);
|
|
83
|
+
};
|
|
84
|
+
/** Seed declared platform packages and their dependency closure without I/O.
|
|
85
|
+
* @yaks packages must use "platform"; none is fetched from a registry. */ export let seed = (files, catalog)=>{
|
|
86
|
+
for (let path of Object.keys(files)){
|
|
87
|
+
if (/^(?:\.\/)*node_modules(?:\/|$)/.test(path)) {
|
|
88
|
+
throw new Error(`${path}: node_modules is the compiler's reserved package namespace`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
let out = {
|
|
92
|
+
files: {
|
|
93
|
+
...files
|
|
94
|
+
},
|
|
95
|
+
assets: {},
|
|
96
|
+
dependencies: {},
|
|
97
|
+
platform: {},
|
|
98
|
+
notes: []
|
|
99
|
+
};
|
|
100
|
+
let noted = (note)=>out.notes.push(note);
|
|
101
|
+
let roots = dependencies(files['package.json'] ?? null);
|
|
102
|
+
let npm = [];
|
|
103
|
+
let visit = (name, version)=>{
|
|
104
|
+
if (!toolkit(name)) {
|
|
105
|
+
if (version == 'platform') {
|
|
106
|
+
throw new Error(`${name}: only @yaks toolkit packages use "platform"`);
|
|
107
|
+
}
|
|
108
|
+
npm.push([
|
|
109
|
+
name,
|
|
110
|
+
version
|
|
111
|
+
]);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (version != 'platform') {
|
|
115
|
+
throw new Error(`${name}: use "platform", not ${version}, in dependencies`);
|
|
116
|
+
}
|
|
117
|
+
if (name in out.platform) return;
|
|
118
|
+
let pkg = catalog[name];
|
|
119
|
+
if (!pkg) {
|
|
120
|
+
throw new Error(`${name}: missing from this compiler's platform catalog`);
|
|
121
|
+
}
|
|
122
|
+
if (!/^sha256:[a-f0-9]{64}$/.test(pkg.version)) {
|
|
123
|
+
throw new Error(`${name}: platform catalog version must be a source SHA256`);
|
|
124
|
+
}
|
|
125
|
+
if (!('package.json' in pkg.files)) {
|
|
126
|
+
throw new Error(`${name}: platform catalog is missing package.json`);
|
|
127
|
+
}
|
|
128
|
+
out.platform[name] = pkg.version;
|
|
129
|
+
for (let [path, source] of Object.entries(pkg.files)){
|
|
130
|
+
if (!safe(path)) {
|
|
131
|
+
throw new Error(`${name}: platform catalog path ${path} is not package-relative`);
|
|
132
|
+
}
|
|
133
|
+
out.files[`node_modules/${name}/${path}`] = source;
|
|
134
|
+
}
|
|
135
|
+
for (let [path, text] of Object.entries(pkg.resources ?? {})){
|
|
136
|
+
if (!safe(path)) {
|
|
137
|
+
throw new Error(`${name}: resource ${path} is not package-relative`);
|
|
138
|
+
}
|
|
139
|
+
out.assets[`${ASSETS}${name}/${path}`] = text;
|
|
140
|
+
out.files[`node_modules/${name}/${path}`] = text;
|
|
141
|
+
}
|
|
142
|
+
for (let [dep, range] of Object.entries(pkg.dependencies))visit(dep, range);
|
|
143
|
+
};
|
|
144
|
+
for (let [name, range] of Object.entries(roots))visit(name, range);
|
|
145
|
+
let npmNames = new Set(npm.map(([name])=>name));
|
|
146
|
+
let renderer = Object.values(catalog).map((p)=>p.renderer).find((r)=>r && npmNames.has(r.dependency) && (!r.unless || !roots[r.unless]));
|
|
147
|
+
if (renderer) {
|
|
148
|
+
out.aliases = renderer.aliases;
|
|
149
|
+
out.jsxImportSource = renderer.dependency;
|
|
150
|
+
} else if (roots.preact && !roots.react) {
|
|
151
|
+
out.jsxImportSource = 'preact';
|
|
152
|
+
} else if (roots.react) out.jsxImportSource = 'react';
|
|
153
|
+
for (let [name, version] of npm){
|
|
154
|
+
if (out.aliases?.[name] && !roots[name]) continue;
|
|
155
|
+
let prior = out.dependencies[name];
|
|
156
|
+
out.dependencies[name] = prior ? together(name, prior, version, noted) : version;
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=platform.js.map
|
package/platform.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sources":["./platform.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,+EAA+E;AAC/E,iFAAiF;AACjF,+EAA+E;AAC/E,wCAAwC,GAAG,SAAS,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,iBAA0B;AAC/G,SAAS,KAAK,6BAAsC;AACpD,SAAS,SAAS,EAAE,MAAM,qBAAoB;AAC9C,SAAS,YAAY,oBAAmB;AAqCxC,0EAA0E,GAC1E,OAAO,IAAI,aAAa,CAAC,OAAa,OACpC,UAAU,MAAM,OAAO,EAAE,CAAC,KAAK,IAAI,SAAS,UAAS;AAEvD,wDAAwD,GACxD,OAAO,IAAI,SAAS,cAAa;AAEjC,IAAI,UAAU,CAAC,OAAiB,KAAK,UAAU,CAAC;AAChD,IAAI,OAAO,CA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