chore(web): fix Next.js build — transpile @learnpro/sandbox + alias .js → .ts#23
Merged
chore(web): fix Next.js build — transpile @learnpro/sandbox + alias .js → .ts#23
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pre-existing latent issue:
pnpm --filter @learnpro/web buildhas been failing since STORY-006 merged withModule not found: Can't resolve './piston-http-transport.js' / './registry.js' / './telemetry.js'. CI didn't catch it because there was noBuildstep.Two fixes in
apps/web/next.config.ts:@learnpro/sandboxtotranspilePackagesso SWC transpiles it.webpack.resolve.extensionAlias = { ".js": [".ts", ".tsx", ".js"], ".mjs": [".mts", ".mjs"] }so webpack follows NodeNext-style.jsimports to the actual.tssource.transpilePackagesalone isn't enough — webpack's resolver doesn't follow.jsto.tsby default. TheextensionAliasis the standard fix for NodeNext ESM under webpack.Also added a
Buildstep to.github/workflows/ci.ymlafterTestso this regression can't recur silently.Test plan
pnpm --filter @learnpro/web buildproduces a clean production bundle (6 routes, ~102 kB shared first-load JS)pnpm -r typecheckcleanpnpm -r lintcleanpnpm -r testall greenpnpm format:checkclean🤖 Generated with Claude Code