stx codemod and stx typecheck both fail on every invocation from the published package:
$ bunx stx codemod "resources/views/**/*.stx"
ReferenceError: awaitPromise is not definedReproduces on a one-line throwaway file, so it is not input-dependent. @stacksjs/stx@0.2.170, via node_modules/.bin/stx -> ../@stacksjs/stx/dist/cli.js.
Cause
The source is correct — packages/stx/bin/cli.ts:1852:
const { Glob } = await import('bun')The bundler inlines the bun builtin import to await Promise.resolve(globalThis.Bun), which is a fine rewrite, but the space between await and Promise is lost. dist/cli.js contains:
{Glob:K}=awaitPromise.resolve(globalThis.Bun)awaitPromise is never defined anywhere in the file — grep -c awaitPromise dist/cli.js returns 2, and there is no declaration for either. Both occurrences are the same pattern, in the two commands that use it:
- line 27096, the
typecheckaction - line 27101, the
codemodaction
So both commands are 100% broken in the shipped artifact while the source and its tests are fine. Anything that runs the CLI from a source checkout works, which is presumably why it has gone unnoticed.
Impact
stx codemod is the tool stx#1843 shipped to measure primitive adoption, and it cannot be run by any consumer installing from npm. Same for stx typecheck.
Workaround until a release: invoke the CLI from a checkout.
bun /path/to/stx/packages/stx/bin/cli.ts codemod --rule tooltip "…/**/*.stx"Suggested check
Worth a smoke test that actually executes each CLI command's action from the built dist/, rather than testing the source only. A bundler mangling an await into an identifier is invisible to any test that imports the source.
Found while trying to run the codemod against stacksjs/stacks#2290.