browserify-incremental icon indicating copy to clipboard operation
browserify-incremental copied to clipboard

Exposed module requiring other exposed module results in error when using cache

Open thedufer opened this issue 10 years ago • 2 comments

For a minimal example, put in file a.js:

module.exports = 'hi';

And in file b.js:

module.exports = require('a');

And compile with browserifyinc --require ./a.js:a --require ./b.js:b. The first time this works fine; the second (after filling the cache) it results in Error: ENOENT, open 'a'. This is because the cache contains

      "deps": {
        "a": "a"
      }

We should not try to open that, since it is a module name and not a file path.

  • Note: The module.exports setting is irrelevant, but useful if you want to see that this is a meaningful thing to do. In file c.js:
console.log(require('a'))
console.log(require('b'))

And then compile with browserifyinc --external a --external b c.js. When run after the first bundle, this will print 'hi' twice.

thedufer avatar Oct 23 '15 22:10 thedufer

This might actually be a browserify issue. I've submitted a PR there, so we'll see.

thedufer avatar Oct 26 '15 17:10 thedufer

I've opened a ticket on browserify-cache-api that might be related to this: https://github.com/jsdf/browserify-cache-api/issues/10

VanCoding avatar Oct 11 '16 12:10 VanCoding