Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Bug: Shouldn't fall back to pkg name in the absence of output flag & pkg main

Open
#884 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
build-system

Research direction

Start in src/index.js around the linked replaceName() calls at lines 255-260 and 297-303, then trace mainNoExtension at lines 219-225. Reproduce the package example with exports pointing to dist/bar.js and no output or main fields. Done means valid preferred filenames from package metadata are preserved while mainNoExtension remains only a fallback, with existing behavior checked for regressions.

Written by the indexing model from the issue text.

Description

Packages that don't use the output flag or have a "main" in their package.json have their preferred filename output ignored.

For example, say I have the following package:

{
  "name": "foo",
  "exports": {
    ".": "./dist/bar.js",
    ...
  }
}

Unfortunately, because of the replaceName() here, the desired output is replaced by the package name instead.

https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L297-L303

https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L255-L260

mainNoExtension traces back to here, which defines a couple of fallbacks.

https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L219-L225

I can't really say that I understand why this was done in the first place, so don't want to go "fixing" it as there might be some relying on this. To me, it seems like that in the absence of the output flag, these fields should be read and used exactly, no replacing.

mainNoExtension seems like it should be the last of the fallbacks, not something that overwrites valid entries & chosen names.

Dominant language
JavaScript
Stars
8.1k
Forks
358
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developit/microbundle

All issues in developit/microbundle

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.