Commit 2c5a9f4
feat: make packages/ai ESM-only (#265)
## Summary
- switch `packages/ai` tsup output to ESM-only
- remove CommonJS export conditions and `.cjs`/`.d.cts` references from
`packages/ai/package.json`
- keep explicit Node-only path/require handling in eval runtime
(`run-vitest.ts`, `context/manager.ts`) without global tsup shims
## Why
- avoids the Workers startup regression caused by global tsup ESM shims
initialization
- aligns package distribution with ESM-only direction
## Validation
- `pnpm --filter axiom build`
- verified `check-vitest-entrypoints` passes
- verified no `.cjs` or `.d.cts` artifacts are produced in
`packages/ai/dist`
## Breaking change
- `packages/ai` no longer supports CommonJS `require(...)` consumers;
users must import via ESM.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk because it removes CommonJS support (breaking for
`require` consumers) and changes package entry/export behavior; the new
Wrangler smoke test should catch runtime regressions in Workers startup.
>
> **Overview**
> Switches `packages/ai` distribution to **ESM-only** by emitting only
`esm` from `tsup` and simplifying `package.json` (`main`/`exports`) to
remove all CommonJS (`.cjs`/`.d.cts`) conditions.
>
> Updates Node-only eval runtime code to avoid reliance on tsup global
shims by resolving `require`/`__dirname` safely in both CJS and ESM
(`context/manager.ts`, `run-vitest.ts`).
>
> Adds a CI `Wrangler Smoke` GitHub Action plus a Vitest smoke suite and
Workers fixture that packs the package, installs it into a minimal
Wrangler app, boots `wrangler dev --local`, and verifies a request can
call `axiom/ai` APIs; TS config excludes fixture/smoke files from normal
typechecking.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e4c1fee. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Christopher Ehrlich <ehrlich.christopher@gmail.com>1 parent d3b8dd0 commit 2c5a9f4
File tree
12 files changed
+293
-65
lines changed- .github/workflows
- packages/ai
- src/evals
- context
- test
- build
- fixtures/wrangler-smoke
- src
- evals
12 files changed
+293
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 32 | + | |
| 33 | + | |
39 | 34 | | |
40 | 35 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 36 | + | |
| 37 | + | |
49 | 38 | | |
50 | 39 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 40 | + | |
| 41 | + | |
59 | 42 | | |
60 | 43 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 44 | + | |
| 45 | + | |
69 | 46 | | |
70 | 47 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 48 | + | |
| 49 | + | |
79 | 50 | | |
80 | 51 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 52 | + | |
| 53 | + | |
89 | 54 | | |
90 | 55 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 56 | + | |
| 57 | + | |
99 | 58 | | |
100 | 59 | | |
101 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
29 | 39 | | |
30 | 40 | | |
31 | 41 | | |
32 | | - | |
33 | | - | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
15 | 26 | | |
16 | 27 | | |
17 | 28 | | |
| |||
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
120 | | - | |
| 131 | + | |
121 | 132 | | |
122 | 133 | | |
123 | 134 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments