Skip to content

chore(web): fix Next.js build — transpile @learnpro/sandbox + alias .js → .ts#23

Merged
khoks merged 1 commit intomainfrom
chore/web-build-transpile
Apr 29, 2026
Merged

chore(web): fix Next.js build — transpile @learnpro/sandbox + alias .js → .ts#23
khoks merged 1 commit intomainfrom
chore/web-build-transpile

Conversation

@khoks
Copy link
Copy Markdown
Owner

@khoks khoks commented Apr 29, 2026

Summary

Pre-existing latent issue: pnpm --filter @learnpro/web build has been failing since STORY-006 merged with Module not found: Can't resolve './piston-http-transport.js' / './registry.js' / './telemetry.js'. CI didn't catch it because there was no Build step.

Two fixes in apps/web/next.config.ts:

  1. Added @learnpro/sandbox to transpilePackages so SWC transpiles it.
  2. Added webpack.resolve.extensionAlias = { ".js": [".ts", ".tsx", ".js"], ".mjs": [".mts", ".mjs"] } so webpack follows NodeNext-style .js imports to the actual .ts source.

transpilePackages alone isn't enough — webpack's resolver doesn't follow .js to .ts by default. The extensionAlias is the standard fix for NodeNext ESM under webpack.

Also added a Build step to .github/workflows/ci.yml after Test so this regression can't recur silently.

Test plan

  • pnpm --filter @learnpro/web build produces a clean production bundle (6 routes, ~102 kB shared first-load JS)
  • pnpm -r typecheck clean
  • pnpm -r lint clean
  • pnpm -r test all green
  • pnpm format:check clean

🤖 Generated with Claude Code

…js → .ts

`pnpm --filter @learnpro/web build` has been failing since STORY-006 with
`Module not found: Can't resolve './piston-http-transport.js' /
'./registry.js' / './telemetry.js'` because:

  1. `@learnpro/sandbox` source uses NodeNext-style `.js` extensions on
     relative imports, but it was missing from `transpilePackages` so
     Next.js's webpack pass didn't run it through SWC.
  2. Even with `transpilePackages`, webpack's resolver doesn't follow
     `.js` to a `.ts` source file by default. The standard fix is
     `webpack.resolve.extensionAlias = { ".js": [".ts", ".tsx", ".js"] }`.

Both fixes land in `apps/web/next.config.ts` with a comment explaining the
rule for future workspace packages added to the web bundle.

Added a `Build` step to `.github/workflows/ci.yml` after `Test` so this
regression can't slip back in unnoticed.

Verified: `pnpm --filter @learnpro/web build` now produces a clean Next.js
production bundle (6 routes, ~102 kB shared first-load JS). All other gates
remain green: typecheck / lint / test / format:check.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@khoks khoks merged commit 4e7ea2b into main Apr 29, 2026
1 check passed
@khoks khoks deleted the chore/web-build-transpile branch April 29, 2026 04:36
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.

1 participant