fix: add .js extensions to relative imports for ESM compatibility#13
Merged
tnkshuuhei merged 1 commit intomainfrom Mar 13, 2026
Merged
fix: add .js extensions to relative imports for ESM compatibility#13tnkshuuhei merged 1 commit intomainfrom
tnkshuuhei merged 1 commit intomainfrom
Conversation
TypeScript compiler preserves bare module specifiers in compiled output, which breaks ESM resolution in Node.js environments (Next.js, Mastra). Add explicit .js extensions to all relative imports so the compiled dist/ output works correctly as an ES module package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merged
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
.jsfile extensions to all relative import/export statements in source TypeScript filesbundle-content.tsgenerated code templates to include.jsextensionsdist/output works correctly as an ES module package in Node.js environments (Next.js, Mastra)Problem
The TypeScript compiler (
tsc) preserves bare module specifiers (e.g.,from "./types") verbatim in compiled output. Since this package uses"type": "module", Node.js ESM resolution requires explicit file extensions (from "./types.js"). Without them, module resolution fails in strict ESM environments.Currently, the
museproject works around this with a patch file (patches/@beaconlabs-io%2Fevidence@1.1.3.patch). This fix addresses the root cause so the patch can be removed.Changes
src/index.ts./types→./types.js,./content→./content/index.jssrc/content/index.ts../types→../types.js,./evidence→./evidence.js,./deployments→./deployments.jsscripts/bundle-content.ts../types→../types.js(2 places)Test plan
bun run buildcompletes successfullydist/index.jscontainsfrom "./types.js"andfrom "./content/index.js"dist/content/index.jscontains.jsextensions on all relative importsmuse/and verifybun dev/bun run buildwork🤖 Generated with Claude Code