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

Dedupe regression with browserify v8

Open
#51 19 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the deduplication scenario with factor-bundle and browserify 8.0.0, comparing the generated A bundle with the browserify v7 output shown here. Trace how the common bundle and A bundle reference module IDs 100 and 200. Done means the deduped module loads without the reported TypeError while preserving the distinct-dependency case.

Written by the indexing model from the issue text.

Description

I'm logging the issue here, but the error is due to changes in browserify 8.0.0.

This might be best explained with an example:

  • Module A depends on module B
  • Other modules depend on module B', which is identical to B but a separate copy exists for whatever reason
  • B is deduped by browserify and points to B'
  • B gets routed to the A bundle, assigned ID of 200
  • B' gets routed to the common bundle, assigned ID of 100
  • Page includes common bundle then A bundle

A bundle in browserify v7:

200:[function(require,module,exports){
module.exports=require(100)
},{"dup":100}]}

A bundle in browserify v8:

200:[function(require,module,exports){
arguments[4][100][0].apply(exports,arguments)
},{"dup":100}]}

This results in an exception Uncaught TypeError: Cannot read property '0' of undefined because ID 100 is not defined in the current bundle.

This worked in v7 because it used require, which tries to resolve the module with previously defined requires from other bundles.

I realize this is an edge case and that if npm is correctly deduping dependencies, this situation should not occur. And the v8 behaviour is more correct in theory because B may have different dependencies from B'. However, assuming that any module is defined in the current bundle is dangerous when factor-bundle is involved.

Dominant language
JavaScript
Stars
397
Forks
24
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 browserify/factor-bundle

All issues in browserify/factor-bundle

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.