browserify / browserify/browserify

External modules fires package event with __dirname=/

Open
#1,281 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.7k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

I noticed that when you have external modules declared that are relative paths, and you perform a `bundle()` `browserify` fires the `package` callback with a package argument `{ __dirname: '/' }`.

Here is an example project (based on the robot/beep/boop example in the `examples` directory of browserify): [https://github.com/caleb/browserify-external-package-bug](https://github.com/caleb/browserify-external-package-bug)

To see the problem, just run `node build.js` in the example project

build.js:

``` js
var browserify = require("browserify");

var b = browserify();
b.add("./beep.js");
b.external("./robot.js");
b.on("package", function(pkg) {
console.log(pkg);
});
b.bundle();
```

When you do you will see the output:

``` js
{ name: 'multiple_bundles',
version: '1.0.0',
description: '',
main: 'beep.js',
dependencies: { browserify: '^10.2.1' },
devDependencies: {},
scripts: { test: 'echo "Error: no test specified" && exit 1' },
repository:
{ type: 'git',
url: 'git+https://github.com/caleb/browserify-external-package-bug.git' },
author: '',
license: 'ISC',
bugs: { url: 'https://github.com/caleb/browserify-external-package-bug/issues' },
homepage: 'https://github.com/caleb/browserify-external-package-bug#readme',
__dirname: '/Users/caleb/Desktop/multiple_bundles' }
{ __dirname: '/' }
```

Is this expected?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.