Skip to content

fix(extension): generate wxt types during install so the documented checks work - #499

Merged
iuyo5678 merged 1 commit into
Tencent:mainfrom
u7-u7:fix/extension-wxt-types-on-install
Oct 27, 2026
Merged

iuyo5678 merged 1 commit into
Tencent:mainfrom
u7-u7:fix/extension-wxt-types-on-install

Conversation

@u7-u7

@u7-u7 u7-u7 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Problem

A fresh checkout cannot typecheck or test the extension. apps/extension/tsconfig.json (tracked) extends ./.wxt/tsconfig.json, which is gitignored and only produced by wxt prepare. Nothing generates it during install, so the commands README lists for checks fail immediately:

$ rm -rf apps/extension/.wxt          # same state as a fresh checkout
$ pnpm --filter @browser-skill/extension compile
> tsc --noEmit
error TS2318: Cannot find global type 'AsyncIterableIterator'.
error TS2318: Cannot find global type 'IterableIterator'.
# exit 2

$ pnpm --filter @browser-skill/extension test
 [TSCONFIG_ERROR] Failed to load tsconfig for 'src/vitest-setup.ts': Tsconfig not found
 Test Files  212 failed (212)
# exit 1

Root cause

The generated .wxt/ tree is a build input that install never produces:

  • wxt build and wxt dev generate it as a side effect, so the order "install, build, test" happens to work;
  • .github/workflows/ci.yml therefore needs a dedicated workaround step (pnpm --filter @browser-skill/extension exec wxt prepare) before compile/ext:test;
  • anyone who runs the documented check commands before building (new contributor, reviewer pulling a PR branch, git clean -xdf in the extension) gets 212 failing test files and a broken tsc, which looks like a broken branch rather than missing generated types.

Fix

Run the generator from the extension package's postinstall script:

     "test": "vitest run",
-    "test:watch": "vitest"
+    "test:watch": "vitest",
+    "postinstall": "wxt prepare"

This is the layout WXT projects use, and it makes pnpm install leave the working tree in a state where the documented checks work. No dependency, lockfile, CI, or product code is touched; CI's explicit prepare step stays valid (now redundant) and I left it alone.

Reproduction and verification

$ rm -rf apps/extension/.wxt                       # simulate a fresh checkout
$ pnpm install --frozen-lockfile
apps/extension postinstall$ wxt prepare
apps/extension postinstall: WXT 0.20.26
apps/extension postinstall: ℹ Generating types...
apps/extension postinstall: ✔ Finished in 888 ms
apps/extension postinstall: Done
Done in 4s using pnpm v10.17.0
# exit 0

$ ls apps/extension/.wxt
tsconfig.json
types
wxt.d.ts

$ pnpm --filter @browser-skill/extension compile
> tsc --noEmit
# exit 0

$ pnpm ext:test
 Test Files  1 failed | 177 passed | 34 skipped (212)
      Tests  1 failed | 2972 passed | 263 skipped (3236)
# exit 1   (see below)

The 212 type-less failures are gone: 2972 tests now run. The single remaining failure is not caused by this change and is not fixed here: src/long-screenshot/png.test.ts > encodes 120,000 exact scanlines across tile and compression boundaries exceeded vitest's default 5000 ms timeout (6065ms) under full-suite parallelism. In three full-suite runs I got 2972 passing tests each time and exactly one default-timeout failure, on a different heavy test each run (png.test.ts twice; once human-loop.test.ts > bounds dangerous URL regex checks in a child process, whose own spawnSync budget is 10 s but which vitest kills at 5 s). Both pass in isolation (png.test.ts: 12/12 in 2.8 s). I kept this patch single-purpose instead of also raising testTimeout — happy to send that as a separate PR if you want it.

Impact and risk

  • Affects local development install only: one extra wxt prepare (~1 s) per pnpm install for the workspace package.
  • No change to the extension runtime, the CLI, the protocol, or the lockfile (pnpm install --frozen-lockfile still passes).
  • If you would rather keep install script-free, the alternative is a README line in "For Developers" telling contributors to run wxt prepare (or pnpm ext:build) before pnpm ext:test; that is strictly a documentation fix and leaves the trap in place for reviewers and git clean -xdf.

AI assistance: this patch was prepared with AI assistance; I reproduced the failure and verified the fix with the commands above.

apps/extension/tsconfig.json (tracked) extends ./.wxt/tsconfig.json, which is
gitignored and only produced by `wxt prepare`. Nothing generates it on install,
so a fresh checkout cannot typecheck or run the extension tests:

  $ pnpm --filter @browser-skill/extension compile
  error TS2318: Cannot find global type 'AsyncIterableIterator'.      (exit 2)

  $ pnpm ext:test
  [TSCONFIG_ERROR] Failed to load tsconfig for 'src/vitest-setup.ts':
  Tsconfig not found
  Test Files  212 failed (212)                                        (exit 1)

`wxt build` and `wxt dev` happen to generate the types as a side effect, and
CI works around the gap with an explicit prepare step, but the commands README
lists for checks (`pnpm ext:test`) do not.

Running `wxt prepare` from the extension's postinstall script makes
`pnpm install` leave the repository in a state where the documented checks
work, which is the layout WXT projects use.

Verified: rm -rf apps/extension/.wxt && pnpm install --frozen-lockfile
regenerates the types (exit 0), then compile exits 0 and the extension test
suite runs (2972 tests passed).
@iuyo5678
iuyo5678 merged commit 6469c47 into Tencent:main Oct 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants