alchemy 2.0.0-beta.18 → 2.0.0-beta.19
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/bin/alchemy.js +428 -80
- package/bin/alchemy.js.map +1 -1
- package/bin/alchemy.ts +2 -0
- package/bin/commands/_shared.ts +34 -0
- package/bin/commands/bootstrap.ts +10 -3
- package/bin/commands/deploy.ts +23 -3
- package/bin/commands/login.ts +18 -3
- package/bin/commands/logs.ts +11 -2
- package/bin/commands/profile.ts +11 -5
- package/bin/commands/state.ts +21 -13
- package/bin/commands/tail.ts +10 -2
- package/lib/Agent/lsp/client.d.ts +2 -2
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +41 -9
- package/lib/Apply.js.map +1 -1
- package/lib/Axiom/Annotation.d.ts +49 -0
- package/lib/Axiom/Annotation.d.ts.map +1 -0
- package/lib/Axiom/Annotation.js +74 -0
- package/lib/Axiom/Annotation.js.map +1 -0
- package/lib/Axiom/ApiToken.d.ts +62 -0
- package/lib/Axiom/ApiToken.d.ts.map +1 -0
- package/lib/Axiom/ApiToken.js +98 -0
- package/lib/Axiom/ApiToken.js.map +1 -0
- package/lib/Axiom/AuthProvider.d.ts +48 -0
- package/lib/Axiom/AuthProvider.d.ts.map +1 -0
- package/lib/Axiom/AuthProvider.js +177 -0
- package/lib/Axiom/AuthProvider.js.map +1 -0
- package/lib/Axiom/Chart.d.ts +72 -0
- package/lib/Axiom/Chart.d.ts.map +1 -0
- package/lib/Axiom/Chart.js +14 -0
- package/lib/Axiom/Chart.js.map +1 -0
- package/lib/Axiom/Credentials.d.ts +12 -0
- package/lib/Axiom/Credentials.d.ts.map +1 -0
- package/lib/Axiom/Credentials.js +34 -0
- package/lib/Axiom/Credentials.js.map +1 -0
- package/lib/Axiom/Dashboard.d.ts +124 -0
- package/lib/Axiom/Dashboard.d.ts.map +1 -0
- package/lib/Axiom/Dashboard.js +140 -0
- package/lib/Axiom/Dashboard.js.map +1 -0
- package/lib/Axiom/Dataset.d.ts +101 -0
- package/lib/Axiom/Dataset.d.ts.map +1 -0
- package/lib/Axiom/Dataset.js +183 -0
- package/lib/Axiom/Dataset.js.map +1 -0
- package/lib/Axiom/Monitor.d.ts +74 -0
- package/lib/Axiom/Monitor.d.ts.map +1 -0
- package/lib/Axiom/Monitor.js +103 -0
- package/lib/Axiom/Monitor.js.map +1 -0
- package/lib/Axiom/Notifier.d.ts +63 -0
- package/lib/Axiom/Notifier.d.ts.map +1 -0
- package/lib/Axiom/Notifier.js +83 -0
- package/lib/Axiom/Notifier.js.map +1 -0
- package/lib/Axiom/Providers.d.ts +15 -0
- package/lib/Axiom/Providers.d.ts.map +1 -0
- package/lib/Axiom/Providers.js +32 -0
- package/lib/Axiom/Providers.js.map +1 -0
- package/lib/Axiom/View.d.ts +55 -0
- package/lib/Axiom/View.d.ts.map +1 -0
- package/lib/Axiom/View.js +79 -0
- package/lib/Axiom/View.js.map +1 -0
- package/lib/Axiom/VirtualField.d.ts +42 -0
- package/lib/Axiom/VirtualField.d.ts.map +1 -0
- package/lib/Axiom/VirtualField.js +71 -0
- package/lib/Axiom/VirtualField.js.map +1 -0
- package/lib/Axiom/index.d.ts +13 -0
- package/lib/Axiom/index.d.ts.map +1 -0
- package/lib/Axiom/index.js +13 -0
- package/lib/Axiom/index.js.map +1 -0
- package/lib/Bundle/Bundle.d.ts +20 -2
- package/lib/Bundle/Bundle.d.ts.map +1 -1
- package/lib/Bundle/Bundle.js +18 -3
- package/lib/Bundle/Bundle.js.map +1 -1
- package/lib/Bundle/PurePlugin.d.ts +109 -0
- package/lib/Bundle/PurePlugin.d.ts.map +1 -0
- package/lib/Bundle/PurePlugin.js +469 -0
- package/lib/Bundle/PurePlugin.js.map +1 -0
- package/lib/Bundle/index.d.ts +1 -0
- package/lib/Bundle/index.d.ts.map +1 -1
- package/lib/Bundle/index.js +1 -0
- package/lib/Bundle/index.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +12 -0
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +19 -4
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +1 -1
- package/lib/Output.js.map +1 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +10 -4
- package/lib/Plan.js.map +1 -1
- package/lib/Resource.d.ts +2 -2
- package/lib/Resource.d.ts.map +1 -1
- package/lib/Telemetry/Attributes.d.ts +43 -0
- package/lib/Telemetry/Attributes.d.ts.map +1 -0
- package/lib/Telemetry/Attributes.js +144 -0
- package/lib/Telemetry/Attributes.js.map +1 -0
- package/lib/Telemetry/Layer.d.ts +14 -0
- package/lib/Telemetry/Layer.d.ts.map +1 -0
- package/lib/Telemetry/Layer.js +50 -0
- package/lib/Telemetry/Layer.js.map +1 -0
- package/lib/Telemetry/Metrics.d.ts +34 -0
- package/lib/Telemetry/Metrics.d.ts.map +1 -0
- package/lib/Telemetry/Metrics.js +57 -0
- package/lib/Telemetry/Metrics.js.map +1 -0
- package/package.json +12 -1
- package/src/Apply.ts +118 -9
- package/src/Axiom/Annotation.ts +95 -0
- package/src/Axiom/ApiToken.ts +125 -0
- package/src/Axiom/AuthProvider.ts +341 -0
- package/src/Axiom/Chart.ts +94 -0
- package/src/Axiom/Credentials.ts +70 -0
- package/src/Axiom/Dashboard.ts +192 -0
- package/src/Axiom/Dataset.ts +291 -0
- package/src/Axiom/Monitor.ts +122 -0
- package/src/Axiom/Notifier.ts +104 -0
- package/src/Axiom/Providers.ts +58 -0
- package/src/Axiom/View.ts +106 -0
- package/src/Axiom/VirtualField.ts +90 -0
- package/src/Axiom/index.ts +12 -0
- package/src/Bundle/Bundle.ts +39 -1
- package/src/Bundle/PurePlugin.ts +556 -0
- package/src/Bundle/index.ts +1 -0
- package/src/Cloudflare/Workers/Worker.ts +37 -6
- package/src/Output.ts +2 -1
- package/src/Plan.ts +13 -4
- package/src/Resource.ts +2 -2
- package/src/Telemetry/Attributes.ts +216 -0
- package/src/Telemetry/Layer.ts +65 -0
- package/src/Telemetry/Metrics.ts +101 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import picomatch from "picomatch";
|
|
5
|
+
import { parseAst } from "rolldown/parseAst";
|
|
6
|
+
/**
|
|
7
|
+
* Default packages whose modules will receive `/*#__PURE__*\/` annotations.
|
|
8
|
+
* Mirrors what `effect-smol` ships via `babel-plugin-annotate-pure-calls`
|
|
9
|
+
* applied to its own `dist/` output.
|
|
10
|
+
*
|
|
11
|
+
* `alchemy` is included so its own resources (which consist almost entirely
|
|
12
|
+
* of `Effect.fn(...)`, `Context.Service(...)(...)`, `Layer.effect(...)` and
|
|
13
|
+
* `Data.TaggedError(...)` top-level calls) become tree-shakeable. The
|
|
14
|
+
* package already declares `"sideEffects": false`, so it is safe.
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_PURE_PACKAGES = [
|
|
17
|
+
"effect",
|
|
18
|
+
"@effect/*",
|
|
19
|
+
"alchemy",
|
|
20
|
+
"@alchemy.run/*",
|
|
21
|
+
];
|
|
22
|
+
const PURE_COMMENT = "/*#__PURE__*/ ";
|
|
23
|
+
const SUPPORTED_FILE_RE = /\.(?:m?[jt]sx?|cjs|cts)$/;
|
|
24
|
+
/**
|
|
25
|
+
* Rolldown plugin that injects `/*#__PURE__*\/` annotations on top-level
|
|
26
|
+
* call/new expressions of modules belonging to the configured packages,
|
|
27
|
+
* enabling tree-shaking of `effect`, `@effect/*`, and any user-listed
|
|
28
|
+
* packages without requiring a babel post-build pass.
|
|
29
|
+
*/
|
|
30
|
+
export const purePlugin = (options = {}) => {
|
|
31
|
+
const patterns = options.replaceDefaults
|
|
32
|
+
? [...(options.packages ?? DEFAULT_PURE_PACKAGES)]
|
|
33
|
+
: [...DEFAULT_PURE_PACKAGES, ...(options.packages ?? [])];
|
|
34
|
+
const markSideEffectFreeOpt = options.markSideEffectFree ?? true;
|
|
35
|
+
const autoDetect = options.autoDetectEntryPackage ?? true;
|
|
36
|
+
// Mutable so the `options` hook can append the auto-detected entry
|
|
37
|
+
// package without rebuilding the plugin instance.
|
|
38
|
+
let isMatch = picomatch(patterns);
|
|
39
|
+
// Per-bundle cache of directory -> owning package metadata.
|
|
40
|
+
// Avoids walking the filesystem for every module of a large package.
|
|
41
|
+
const pkgInfoCache = new Map();
|
|
42
|
+
// Resolved absolute paths of entry modules. Marking an entry module as
|
|
43
|
+
// `moduleSideEffects: false` makes rolldown treat its top-level
|
|
44
|
+
// statements (including `console.log` etc.) as eliminable, often
|
|
45
|
+
// collapsing the whole bundle. We always preserve entries' side
|
|
46
|
+
// effects, regardless of the package they belong to.
|
|
47
|
+
const entryPaths = new Set();
|
|
48
|
+
return {
|
|
49
|
+
name: "alchemy:annotate-pure",
|
|
50
|
+
async options(opts) {
|
|
51
|
+
collectEntryPaths(opts, entryPaths);
|
|
52
|
+
if (!autoDetect)
|
|
53
|
+
return null;
|
|
54
|
+
const detected = await detectEntryPackage(opts);
|
|
55
|
+
if (detected === null)
|
|
56
|
+
return null;
|
|
57
|
+
if (patterns.includes(detected))
|
|
58
|
+
return null;
|
|
59
|
+
patterns.push(detected);
|
|
60
|
+
isMatch = picomatch(patterns);
|
|
61
|
+
return null;
|
|
62
|
+
},
|
|
63
|
+
transform: {
|
|
64
|
+
filter: { id: SUPPORTED_FILE_RE },
|
|
65
|
+
async handler(code, id) {
|
|
66
|
+
const info = await resolvePackageInfo(id, pkgInfoCache);
|
|
67
|
+
if (info === null || info.name === null || !isMatch(info.name)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const cleanId = id.replace(/[?#].*$/, "");
|
|
71
|
+
const isEntry = entryPaths.has(cleanId);
|
|
72
|
+
// Only override `moduleSideEffects` when the owning package
|
|
73
|
+
// explicitly opts in via `sideEffects: false` / `[]`. Pure
|
|
74
|
+
// annotations themselves are always safe to add (they only mean
|
|
75
|
+
// "if the result is unused, the call may be dropped"), but
|
|
76
|
+
// marking arbitrary modules side-effect-free could erase
|
|
77
|
+
// intentional registrations / mutations the author made at the
|
|
78
|
+
// top level of files in packages that did not declare so.
|
|
79
|
+
const markSideEffectFree = markSideEffectFreeOpt && !isEntry && isSideEffectFree(info.sideEffects);
|
|
80
|
+
const annotated = annotateModule(code, id);
|
|
81
|
+
if (annotated === null) {
|
|
82
|
+
return markSideEffectFree
|
|
83
|
+
? { code, moduleSideEffects: false }
|
|
84
|
+
: null;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
code: annotated.code,
|
|
88
|
+
map: annotated.map,
|
|
89
|
+
moduleSideEffects: markSideEffectFree ? false : null,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Captures the absolute paths of every entry module declared on the
|
|
97
|
+
* rolldown input options into `out`. Handles all three input shapes:
|
|
98
|
+
* string, array of strings, and `{ name -> path }` record.
|
|
99
|
+
*/
|
|
100
|
+
function collectEntryPaths(opts, out) {
|
|
101
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
102
|
+
const add = (entry) => {
|
|
103
|
+
if (typeof entry !== "string")
|
|
104
|
+
return;
|
|
105
|
+
out.add(path.resolve(cwd, entry));
|
|
106
|
+
};
|
|
107
|
+
if (typeof opts.input === "string")
|
|
108
|
+
add(opts.input);
|
|
109
|
+
else if (Array.isArray(opts.input))
|
|
110
|
+
for (const e of opts.input)
|
|
111
|
+
add(e);
|
|
112
|
+
else if (opts.input && typeof opts.input === "object") {
|
|
113
|
+
for (const e of Object.values(opts.input))
|
|
114
|
+
add(e);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Walks up from each entry path (and `cwd`) to find the nearest
|
|
119
|
+
* `package.json`, and returns its `name` if the package is safely
|
|
120
|
+
* annotatable — i.e. it declares `sideEffects: false` or `[]`. Returns
|
|
121
|
+
* `null` if no entry package can be found, the entry has no name, or the
|
|
122
|
+
* package opts out of side-effect-free treatment.
|
|
123
|
+
*/
|
|
124
|
+
async function detectEntryPackage(opts) {
|
|
125
|
+
const inputs = [];
|
|
126
|
+
if (typeof opts.input === "string")
|
|
127
|
+
inputs.push(opts.input);
|
|
128
|
+
else if (Array.isArray(opts.input))
|
|
129
|
+
inputs.push(...opts.input);
|
|
130
|
+
else if (opts.input && typeof opts.input === "object") {
|
|
131
|
+
inputs.push(...Object.values(opts.input));
|
|
132
|
+
}
|
|
133
|
+
if (opts.cwd)
|
|
134
|
+
inputs.push(opts.cwd);
|
|
135
|
+
if (inputs.length === 0)
|
|
136
|
+
inputs.push(process.cwd());
|
|
137
|
+
for (const candidate of inputs) {
|
|
138
|
+
const meta = await findOwningPackageMeta(candidate);
|
|
139
|
+
if (meta === null || meta.name === null)
|
|
140
|
+
continue;
|
|
141
|
+
return meta.name;
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
async function findOwningPackageMeta(start) {
|
|
146
|
+
// Resolve to absolute and start from the directory containing `start`
|
|
147
|
+
// (or `start` itself if it is already a directory).
|
|
148
|
+
let dir = path.resolve(start);
|
|
149
|
+
try {
|
|
150
|
+
if ((await fs.stat(dir)).isFile())
|
|
151
|
+
dir = path.dirname(dir);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
dir = path.dirname(dir);
|
|
155
|
+
}
|
|
156
|
+
for (let i = 0; i < 64; i++) {
|
|
157
|
+
const pj = path.join(dir, "package.json");
|
|
158
|
+
try {
|
|
159
|
+
const stat = await fs.stat(pj);
|
|
160
|
+
if (stat.isFile()) {
|
|
161
|
+
const contents = await fs.readFile(pj, "utf8");
|
|
162
|
+
const json = JSON.parse(contents);
|
|
163
|
+
return {
|
|
164
|
+
name: typeof json.name === "string" ? json.name : null,
|
|
165
|
+
sideEffects: json.sideEffects,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// keep climbing
|
|
171
|
+
}
|
|
172
|
+
const parent = path.dirname(dir);
|
|
173
|
+
if (parent === dir)
|
|
174
|
+
break;
|
|
175
|
+
dir = parent;
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Mirrors how rolldown / rollup interpret the `sideEffects` package.json
|
|
181
|
+
* field. We only treat `false` and `[]` as "fully side-effect free"; an
|
|
182
|
+
* array of files or `true` is treated as not safe to auto-annotate the
|
|
183
|
+
* whole package.
|
|
184
|
+
*/
|
|
185
|
+
function isSideEffectFree(value) {
|
|
186
|
+
if (value === false)
|
|
187
|
+
return true;
|
|
188
|
+
if (Array.isArray(value) && value.length === 0)
|
|
189
|
+
return true;
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Extracts the npm package name from a resolved module id by walking back to
|
|
194
|
+
* the last `node_modules/` segment. Handles scoped packages. This is the
|
|
195
|
+
* fast path that does not hit the filesystem; it works for ordinary
|
|
196
|
+
* `node_modules/<pkg>/...` ids but NOT for workspace-linked sources whose
|
|
197
|
+
* resolved path is e.g. `<repo>/packages/alchemy/src/Bundle/PurePlugin.ts`.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* packageNameFromId("/proj/node_modules/effect/dist/Effect.js")
|
|
201
|
+
* // => "effect"
|
|
202
|
+
* packageNameFromId("/proj/node_modules/@effect/cluster/dist/index.js")
|
|
203
|
+
* // => "@effect/cluster"
|
|
204
|
+
*/
|
|
205
|
+
export function packageNameFromId(id) {
|
|
206
|
+
const normalized = id.replace(/\\/g, "/");
|
|
207
|
+
const idx = normalized.lastIndexOf("/node_modules/");
|
|
208
|
+
if (idx === -1)
|
|
209
|
+
return null;
|
|
210
|
+
const rest = normalized.slice(idx + "/node_modules/".length);
|
|
211
|
+
const parts = rest.split("/");
|
|
212
|
+
if (parts.length === 0 || parts[0] === "")
|
|
213
|
+
return null;
|
|
214
|
+
if (parts[0].startsWith("@")) {
|
|
215
|
+
if (parts.length < 2)
|
|
216
|
+
return null;
|
|
217
|
+
return `${parts[0]}/${parts[1]}`;
|
|
218
|
+
}
|
|
219
|
+
return parts[0];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Resolves the owning {@link PackageInfo} for a module id by walking up
|
|
223
|
+
* the directory tree to the nearest `package.json`. This is what makes
|
|
224
|
+
* the plugin work for workspace-linked sources (e.g. our own
|
|
225
|
+
* `packages/alchemy/src/**` when consumers import via the `worker`/`bun`
|
|
226
|
+
* conditions which resolve to `.ts`).
|
|
227
|
+
*
|
|
228
|
+
* Caches both positive and negative results per directory to keep the
|
|
229
|
+
* filesystem walk bounded across an entire bundle pass.
|
|
230
|
+
*/
|
|
231
|
+
export async function resolvePackageInfo(id, cache) {
|
|
232
|
+
// Strip rolldown's `?query` / `#hash` suffixes if present.
|
|
233
|
+
const cleanId = id.replace(/[?#].*$/, "");
|
|
234
|
+
// Fast path: id matches `node_modules/<pkg>/...`. We still try to read
|
|
235
|
+
// the package's `package.json` to learn its `sideEffects` field, but if
|
|
236
|
+
// the file is unreadable (or this is a virtual id from a test) we fall
|
|
237
|
+
// back to a minimal record using the path-derived name.
|
|
238
|
+
const fastName = packageNameFromId(cleanId);
|
|
239
|
+
let dir = path.dirname(cleanId);
|
|
240
|
+
// Remember dirs we visited for this lookup so we can backfill their
|
|
241
|
+
// cache entries — but ONLY descendants of the resolved package root.
|
|
242
|
+
// Caching shared ancestors like `/proj/node_modules` would poison
|
|
243
|
+
// sibling packages (e.g. effect and lodash both live under it).
|
|
244
|
+
const visited = [];
|
|
245
|
+
let foundRoot = null;
|
|
246
|
+
let foundInfo = null;
|
|
247
|
+
// Hard ceiling to prevent runaway walks on weird ids.
|
|
248
|
+
for (let i = 0; i < 64; i++) {
|
|
249
|
+
const cached = cache.get(dir);
|
|
250
|
+
if (cached !== undefined) {
|
|
251
|
+
cacheDescendants(cache, visited, dir, cached);
|
|
252
|
+
return cached;
|
|
253
|
+
}
|
|
254
|
+
visited.push(dir);
|
|
255
|
+
const pkgJsonPath = path.join(dir, "package.json");
|
|
256
|
+
let info = null;
|
|
257
|
+
try {
|
|
258
|
+
const stat = await fs.stat(pkgJsonPath);
|
|
259
|
+
if (stat.isFile()) {
|
|
260
|
+
const contents = await fs.readFile(pkgJsonPath, "utf8");
|
|
261
|
+
const json = JSON.parse(contents);
|
|
262
|
+
info = {
|
|
263
|
+
name: typeof json.name === "string" ? json.name : null,
|
|
264
|
+
sideEffects: json.sideEffects,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
// package.json missing or unreadable — keep climbing.
|
|
270
|
+
}
|
|
271
|
+
if (info !== null) {
|
|
272
|
+
foundRoot = dir;
|
|
273
|
+
foundInfo = info;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
const parent = path.dirname(dir);
|
|
277
|
+
if (parent === dir)
|
|
278
|
+
break;
|
|
279
|
+
dir = parent;
|
|
280
|
+
}
|
|
281
|
+
if (foundInfo !== null && foundRoot !== null) {
|
|
282
|
+
cacheDescendants(cache, visited, foundRoot, foundInfo);
|
|
283
|
+
return foundInfo;
|
|
284
|
+
}
|
|
285
|
+
// No `package.json` found on disk. If we have a path-derived name
|
|
286
|
+
// (from a `node_modules/<pkg>/...` segment), use it with no
|
|
287
|
+
// `sideEffects` info — annotation can still happen, the override is
|
|
288
|
+
// gated separately. Cache only the directly-owning dir so we don't
|
|
289
|
+
// poison sibling lookups under the same `node_modules`.
|
|
290
|
+
if (fastName !== null) {
|
|
291
|
+
const fallback = { name: fastName, sideEffects: undefined };
|
|
292
|
+
if (visited[0])
|
|
293
|
+
cache.set(visited[0], fallback);
|
|
294
|
+
return fallback;
|
|
295
|
+
}
|
|
296
|
+
if (visited[0])
|
|
297
|
+
cache.set(visited[0], null);
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Caches `info` only at directories that are at or below `root` — i.e.
|
|
302
|
+
* directories that genuinely belong to the same package. Dirs above the
|
|
303
|
+
* package root are shared with siblings (e.g. `node_modules`) and must
|
|
304
|
+
* not be tagged.
|
|
305
|
+
*/
|
|
306
|
+
function cacheDescendants(cache, visited, root, info) {
|
|
307
|
+
for (const v of visited) {
|
|
308
|
+
if (v === root || isPathInside(v, root))
|
|
309
|
+
cache.set(v, info);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* `true` if `child` is `parent` or a directory contained beneath it.
|
|
314
|
+
* Path-only check; does not touch the filesystem.
|
|
315
|
+
*/
|
|
316
|
+
function isPathInside(child, parent) {
|
|
317
|
+
if (child === parent)
|
|
318
|
+
return true;
|
|
319
|
+
const rel = path.relative(parent, child);
|
|
320
|
+
return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Convenience wrapper that returns just the package name. Equivalent to
|
|
324
|
+
* `resolvePackageInfo(...)?.name ?? packageNameFromId(id)`.
|
|
325
|
+
*/
|
|
326
|
+
export async function resolvePackageName(id, cache) {
|
|
327
|
+
const cleanId = id.replace(/[?#].*$/, "");
|
|
328
|
+
const fast = packageNameFromId(cleanId);
|
|
329
|
+
if (fast !== null)
|
|
330
|
+
return fast;
|
|
331
|
+
// Adapter cache so callers can keep a single-value cache shape.
|
|
332
|
+
const adapter = new Map();
|
|
333
|
+
for (const [k, v] of cache) {
|
|
334
|
+
adapter.set(k, v === null ? null : { name: v, sideEffects: undefined });
|
|
335
|
+
}
|
|
336
|
+
const info = await resolvePackageInfo(cleanId, adapter);
|
|
337
|
+
for (const [k, v] of adapter) {
|
|
338
|
+
cache.set(k, v?.name ?? null);
|
|
339
|
+
}
|
|
340
|
+
return info?.name ?? null;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Parses `code` and inserts `/*#__PURE__*\/` before every top-level
|
|
344
|
+
* `CallExpression` / `NewExpression` callee. Returns `null` if the file
|
|
345
|
+
* does not need to be modified (parse failure or no annotations added).
|
|
346
|
+
*/
|
|
347
|
+
export function annotateModule(code, filename) {
|
|
348
|
+
let program;
|
|
349
|
+
try {
|
|
350
|
+
// Use TS lang so the parser tolerates TS syntax (`as`, `satisfies`,
|
|
351
|
+
// non-null assertions) even when scanning published .js dist files
|
|
352
|
+
// — TS is a strict superset of JS for our purposes here.
|
|
353
|
+
program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
const s = new MagicString(code);
|
|
359
|
+
let mutated = false;
|
|
360
|
+
const annotateCall = (call) => {
|
|
361
|
+
if (isIIFE(call))
|
|
362
|
+
return;
|
|
363
|
+
// For `new X()`, anchor BEFORE the `new` keyword so we get
|
|
364
|
+
// `/*#__PURE__*/ new X()` (matches babel-plugin-annotate-pure-calls).
|
|
365
|
+
const anchor = call.type === "NewExpression" ? call.start : call.callee.start;
|
|
366
|
+
if (alreadyAnnotated(code, anchor))
|
|
367
|
+
return;
|
|
368
|
+
s.appendLeft(anchor, PURE_COMMENT);
|
|
369
|
+
mutated = true;
|
|
370
|
+
};
|
|
371
|
+
const annotateExpression = (expr) => {
|
|
372
|
+
if (!expr)
|
|
373
|
+
return;
|
|
374
|
+
switch (expr.type) {
|
|
375
|
+
case "CallExpression":
|
|
376
|
+
case "NewExpression":
|
|
377
|
+
annotateCall(expr);
|
|
378
|
+
return;
|
|
379
|
+
case "SequenceExpression":
|
|
380
|
+
for (const inner of expr.expressions)
|
|
381
|
+
annotateExpression(inner);
|
|
382
|
+
return;
|
|
383
|
+
case "ParenthesizedExpression":
|
|
384
|
+
annotateExpression(expr.expression);
|
|
385
|
+
return;
|
|
386
|
+
case "LogicalExpression":
|
|
387
|
+
annotateExpression(expr.left);
|
|
388
|
+
annotateExpression(expr.right);
|
|
389
|
+
return;
|
|
390
|
+
case "ConditionalExpression":
|
|
391
|
+
annotateExpression(expr.consequent);
|
|
392
|
+
annotateExpression(expr.alternate);
|
|
393
|
+
return;
|
|
394
|
+
case "AssignmentExpression":
|
|
395
|
+
annotateExpression(expr.right);
|
|
396
|
+
return;
|
|
397
|
+
case "TSAsExpression":
|
|
398
|
+
case "TSSatisfiesExpression":
|
|
399
|
+
case "TSNonNullExpression":
|
|
400
|
+
case "TSTypeAssertion":
|
|
401
|
+
annotateExpression(expr.expression);
|
|
402
|
+
return;
|
|
403
|
+
case "ChainExpression": {
|
|
404
|
+
const inner = expr.expression;
|
|
405
|
+
if (inner.type === "CallExpression")
|
|
406
|
+
annotateCall(inner);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
default:
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
const visitTopLevel = (node) => {
|
|
414
|
+
switch (node.type) {
|
|
415
|
+
case "ExpressionStatement":
|
|
416
|
+
annotateExpression(node.expression);
|
|
417
|
+
return;
|
|
418
|
+
case "VariableDeclaration":
|
|
419
|
+
for (const decl of node.declarations) {
|
|
420
|
+
annotateExpression(decl.init);
|
|
421
|
+
}
|
|
422
|
+
return;
|
|
423
|
+
case "ExportNamedDeclaration": {
|
|
424
|
+
const decl = node.declaration;
|
|
425
|
+
if (decl)
|
|
426
|
+
visitTopLevel(decl);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
case "ExportDefaultDeclaration": {
|
|
430
|
+
const decl = node.declaration;
|
|
431
|
+
if (decl &&
|
|
432
|
+
decl.type !== "FunctionDeclaration" &&
|
|
433
|
+
decl.type !== "ClassDeclaration" &&
|
|
434
|
+
decl.type !== "TSInterfaceDeclaration") {
|
|
435
|
+
annotateExpression(decl);
|
|
436
|
+
}
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
default:
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
for (const node of program.body) {
|
|
444
|
+
// Directive nodes (e.g. "use strict") have type "ExpressionStatement"
|
|
445
|
+
// with a `directive` field and a string literal expression — they
|
|
446
|
+
// cannot contain calls, so visiting them is a safe no-op.
|
|
447
|
+
visitTopLevel(node);
|
|
448
|
+
}
|
|
449
|
+
if (!mutated)
|
|
450
|
+
return null;
|
|
451
|
+
return {
|
|
452
|
+
code: s.toString(),
|
|
453
|
+
map: s.generateMap({ source: filename, hires: true, includeContent: true }),
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function isIIFE(node) {
|
|
457
|
+
let callee = node.callee;
|
|
458
|
+
while (callee.type === "ParenthesizedExpression") {
|
|
459
|
+
callee = callee.expression;
|
|
460
|
+
}
|
|
461
|
+
return (callee.type === "FunctionExpression" ||
|
|
462
|
+
callee.type === "ArrowFunctionExpression");
|
|
463
|
+
}
|
|
464
|
+
function alreadyAnnotated(code, pos) {
|
|
465
|
+
const start = Math.max(0, pos - 32);
|
|
466
|
+
const slice = code.slice(start, pos);
|
|
467
|
+
return slice.includes("/*#__PURE__*/") || slice.includes("/*@__PURE__*/");
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=PurePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PurePlugin.js","sourceRoot":"","sources":["../../src/Bundle/PurePlugin.ts"],"names":[],"mappings":"AAWA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,QAAQ;IACR,WAAW;IACX,SAAS;IACT,gBAAgB;CACjB,CAAC;AAyCF,M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d.ts","sourceRoot":"","sources":["../../src/Bundle/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Bundle/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|
package/lib/Bundle/index.js
CHANGED
package/lib/Bundle/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Bundle/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Bundle/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|
|
@@ -9,6 +9,7 @@ import * as Redacted from "effect/Redacted";
|
|
|
9
9
|
import * as Binding from "../../Binding.ts";
|
|
10
10
|
import { type Artifacts as ArtifactsBinding } from "../Artifacts/Artifacts.ts";
|
|
11
11
|
import { type MemoOptions } from "../../Build/Memo.ts";
|
|
12
|
+
import * as Bundle from "../../Bundle/Bundle.ts";
|
|
12
13
|
import type { InputProps } from "../../Input.ts";
|
|
13
14
|
import * as Output from "../../Output.ts";
|
|
14
15
|
import { Platform, type Main, type PlatformProps, type Rpc } from "../../Platform.ts";
|
|
@@ -142,6 +143,17 @@ export interface WorkerProps<Bindings extends WorkerBindingProps = any, Assets e
|
|
|
142
143
|
* @default false
|
|
143
144
|
*/
|
|
144
145
|
metafile?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Configures the {@link Bundle.purePlugin} which annotates top-level
|
|
148
|
+
* call/new expressions in matching packages with `/*#__PURE__*\/`
|
|
149
|
+
* so rolldown can tree-shake them.
|
|
150
|
+
*
|
|
151
|
+
* - `undefined` (default): plugin is enabled with default packages
|
|
152
|
+
* (`effect`, `@effect/*`).
|
|
153
|
+
* - `PurePluginOptions`: plugin is enabled with the provided options.
|
|
154
|
+
* - `false`: plugin is disabled.
|
|
155
|
+
*/
|
|
156
|
+
pure?: Bundle.BundleExtraOptions["pure"];
|
|
145
157
|
};
|
|
146
158
|
}
|
|
147
159
|
export type Worker<Bindings extends WorkerBindings = any> = Resource<WorkerTypeId, WorkerProps<Bindings>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Workers/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,KAAK,OAAO,MAAM,qCAAqC,CAAC;AAG/D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAW5C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAEL,KAAK,SAAS,IAAI,gBAAgB,EACnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Workers/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,KAAK,OAAO,MAA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AAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE;WACpD;QACL,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B;;eAGU,aAAa,EAAE;iBACb;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE;;;mBADzB,aAAa,EAAE;qBACb;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE;;;mBADzB,aAAa,EAAE;qBACb;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE;;;;;;;;;;;kBATf,MAAM;YAAM,MAAM;gBAAU,MAAM;;;gBAE7C,MAAM,GAAG,SAAS;gBAClB,MAAM,GAAG,SAAS;eACnB,MAAM,GAAG,SAAS;;gIAwkB7B,CAAC;iHAIQ,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;AAFzC,qBAAa,gBAAiB,SAAQ,qBAGT;CAAG;AAEhC,eAAO,MAAM,oBAAoB,6CAkBhC,CAAC;AAwDF,eAAO,MAAM,cAAc,yQAuyCxB,CAAC"}
|
|
@@ -477,7 +477,16 @@ export const Worker = Platform(WorkerTypeId, {
|
|
|
477
477
|
: Effect.die(`Environment variable '${key}' not found`)), Effect.map((json) => {
|
|
478
478
|
try {
|
|
479
479
|
const value = JSON.parse(json);
|
|
480
|
-
|
|
480
|
+
// The `set` path serializes Redacted values as
|
|
481
|
+
// `{_tag: "Redacted", value: ...}`. After JSON.parse the
|
|
482
|
+
// result is a plain object — `Redacted.isRedacted` would
|
|
483
|
+
// always return `false` on it — so detect the marker shape
|
|
484
|
+
// and rebuild the Redacted wrapper. Plain values pass
|
|
485
|
+
// through unchanged.
|
|
486
|
+
if (value !== null &&
|
|
487
|
+
typeof value === "object" &&
|
|
488
|
+
value._tag === "Redacted" &&
|
|
489
|
+
"value" in value) {
|
|
481
490
|
return Redacted.make(value.value);
|
|
482
491
|
}
|
|
483
492
|
return value;
|
|
@@ -488,11 +497,17 @@ export const Worker = Platform(WorkerTypeId, {
|
|
|
488
497
|
})),
|
|
489
498
|
set: (id, output) => Effect.sync(() => {
|
|
490
499
|
const key = id.replaceAll(/[^a-zA-Z0-9]/g, "_");
|
|
500
|
+
// Preserve `Redacted`-ness across the Output → env → Cloudflare
|
|
501
|
+
// binding boundary so the put-worker loop can deploy secrets via
|
|
502
|
+
// `secret_text` instead of leaking them as `plain_text`. The JSON
|
|
503
|
+
// payload still carries the `{_tag: "Redacted", …}` marker so the
|
|
504
|
+
// runtime `get` accessor can rebuild the wrapper after Cloudflare
|
|
505
|
+
// hands the binding back as a plain string.
|
|
491
506
|
env[key] = output.pipe(Output.map((value) => Redacted.isRedacted(value)
|
|
492
|
-
? JSON.stringify({
|
|
507
|
+
? Redacted.make(JSON.stringify({
|
|
493
508
|
_tag: "Redacted",
|
|
494
509
|
value: Redacted.value(value),
|
|
495
|
-
})
|
|
510
|
+
}))
|
|
496
511
|
: JSON.stringify(value)));
|
|
497
512
|
return key;
|
|
498
513
|
}),
|
|
@@ -794,7 +809,7 @@ export const WorkerProvider = () => Provider.effect(Worker, Effect.gen(function*
|
|
|
794
809
|
minify: true,
|
|
795
810
|
keepNames: true,
|
|
796
811
|
dir: `.alchemy/bundles/${id}`,
|
|
797
|
-
});
|
|
812
|
+
}, { pure: props.build?.pure });
|
|
798
813
|
if (props.isExternal) {
|
|
799
814
|
const bundle = yield* buildBundle();
|
|
800
815
|
return bundle;
|