Fix tyndale-next config export#3
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds a CommonJS ChangesTyndale Config Export and Resolution
Sequence Diagram(s)sequenceDiagram
participant NextConfig
participant withTyndaleConfig
participant PackageResolver
participant Filesystem
participant Turbopack
participant Webpack
NextConfig->>withTyndaleConfig: call with {} / existing config
withTyndaleConfig->>PackageResolver: resolvePackageExport('tyndale-react' and './server')
PackageResolver->>Filesystem: read package.json and exports
PackageResolver->>withTyndaleConfig: return resolved physical paths
withTyndaleConfig->>Turbopack: set resolveAlias entries
withTyndaleConfig->>Webpack: remove broad alias, set exact-match alias (tyndale-react$)
withTyndaleConfig->>NextConfig: return augmented config with env and aliases
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/tyndale-next/package.json`:
- Line 41: The build script in package.json currently invokes the Node binary
("scripts.build": "tsc && node -e
\"require('node:fs').copyFileSync('src/config.cjs', 'dist/config.cjs')\""),
which breaks when only Bun is installed; change the copy step to a POSIX/copier
command that works under Bun (for example replace the node -e invocation with
"cp src/config.cjs dist/config.cjs") so the script becomes something like "tsc
&& cp src/config.cjs dist/config.cjs"; update the "build" script in
packages/tyndale-next/package.json (scripts.build) accordingly, or alternatively
implement the copy using a Bun-compatible JS one-liner if you need
cross-platform handling.
In `@packages/tyndale-next/src/config.cjs`:
- Around line 53-65: selectPackageEntry currently assumes a non-array
packageJson.exports object is a subpath map and only inspects exports['.'],
which misses conditional-root exports like { "import": "...", "require": "..."
}; change the logic in selectPackageEntry to first try selectExportPath on the
exportsField itself (i.e., call selectExportPath(exportsField)) and if that
returns undefined then fall back to reading exportsField['.'] (and then to
packageJson.module/packageJson.main/'index.js'); reference selectPackageEntry,
selectExportPath, and exportsField when making the change.
In `@packages/tyndale-next/src/config.ts`:
- Around line 87-99: selectPackageEntry currently treats any object-valued
packageJson.exports as a subpath map and unconditionally uses exports['.'],
which breaks root conditional exports; change selectPackageEntry so it checks if
packageJson.exports is an object and hasOwnProperty('.') — if yes use
exports['.'] as rootExport, otherwise pass the entire exports object into
selectExportPath (which already understands conditional maps); apply the same
fix to the mirrored logic in config.cjs and ensure references to
selectExportPath and packageJson.exports are used as described.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: efc4e355-7bc1-4fc3-8788-767d391d898c
📒 Files selected for processing (6)
packages/tyndale-next/package.jsonpackages/tyndale-next/src/config.cjspackages/tyndale-next/src/config.tspackages/tyndale-next/tests/config.test.tspackages/tyndale-next/tests/exports.test.tstests/e2e/fixture/next.config.mjs
9dd9ca3 to
693ab54
Compare
693ab54 to
cbbb7db
Compare
cbbb7db to
7b27449
Compare
7b27449 to
47b7fe9
Compare
Summary
tyndale-next/configfor both ESM and CommonJS config loadersdistduring package buildswithTyndaleConfigCloses #2.
Review responses
tyndale-nextcopy step fromnode -eto a BunBun.writeone-liner.exportsmaps are passed throughselectExportPath.Verification
bun test --cwd packages/tyndale-nextbun run build:packagesbun test tests/e2e/bun run test:playwrightbunx playwright install --with-deps --only-shell --dry-run chromium