Skip to content

No output written when Browserify.opts.basedir is set #50

Open
@flipchart

Description

When Browserify.opts.basedir is set, all content is written to the common file, and the outputs specified by { outputs: [...] } are blank. Before I realized that it was the Browserify.opts.basedir setting, I found that printing out the row and groups from the threashold function showed some differences (which thus led me to the basedir setting). Below are the outputs from the threashold function using the homepage sample.

basedir not set

    var browserify = require("browserify");
    var fs = require("fs");

    var files = ["./Scripts/test/x.js", "./Scripts/test/y.js"];
    var b = browserify(files);
    b
        .plugin(factor, {
            outputs: ["wwwroot/test/x.js", "wwwroot/test/y.js"], threshold: function (row, groups) {
                console.log(row);
                console.log(groups);

                return this._defaultThreshold(row, groups);
            }
        });
    b
        .bundle()
        .pipe(fs.createWriteStream("wwwroot/common.js"));

*Note the groups array is non-empty and there are 3 files emitted

{ entry: true,
  expose: false,
  basedir: undefined,
  file: './Scripts/test/y.js',
  id: 2,
  order: 1,
  source: 'var z = require(\'./z.js\');\r\nconsole.log(z(2) + 111);',
  deps: { './z.js': 4 },
  index: 2,
  indexDeps: { './z.js': 4 } }
[ 'C:\\path\to\\Scripts\\test\\y.js' ]

{ entry: true,
  expose: false,
  basedir: undefined,
  file: './Scripts/test/x.js',
  id: 1,
  order: 0,
  source: 'var z = require(\'./z.js\');\r\nvar w = require(\'./w.js\');\r\nconsole.log(z(5) * w(2));',
  deps: { './z.js': 4, './w.js': 3 },
  index: 1,
  indexDeps: { './z.js': 4, './w.js': 3 } }
[ 'C:\\path\to\\Scripts\\test\\x.js' ]

{ id: 4,
  source: 'module.exports = function (n) { return n * 111 }',
  deps: {},
  file: 'C:\\path\to\\Scripts\\test\\z.js',
  index: 4,
  indexDeps: {} }
[ 'C:\\path\to\\Scripts\\test\\y.js',
  'C:\\path\to\\Scripts\\test\\x.js' ]
{ id: 3,
  source: 'module.exports = function (n) { return n * 50 }',
  deps: {},
  file: 'C:\\path\to\\Scripts\\test\\w.js',
  index: 3,
  indexDeps: {} }
[ 'C:\\path\to\\Scripts\\test\\x.js' ]

basedir set

    var browserify = require("browserify");
    var fs = require("fs");

    var files = ["./test/x.js", "./test/y.js"];
    var b = browserify(files, { basedir: "./Scripts" });
    b
        .plugin(factor, {
            outputs: ["wwwroot/test/x.js", "wwwroot/test/y.js"], threshold: function (row, groups) {
                console.log(row);
                console.log(groups);

                return this._defaultThreshold(row, groups);
            }
        });
    b
        .bundle()
        .pipe(fs.createWriteStream("wwwroot/common.js"));

Note the groups array is always empty, and only 2 files are emitted

{ entry: true,
  expose: false,
  basedir: './Scripts',
  file: './test/y.js',
  id: 2,
  order: 1,
  source: 'var z = require(\'./z.js\');\r\nconsole.log(z(2) + 111);',
  deps: { './z.js': 4 },
  index: 2,
  indexDeps: { './z.js': 4 } }
[]

{ entry: true,
  expose: false,
  basedir: './Scripts',
  file: './test/x.js',
  id: 1,
  order: 0,
  source: 'var z = require(\'./z.js\');\r\nvar w = require(\'./w.js\');\r\nconsole.log(z(5) * w(2));',
  deps: { './z.js': 4, './w.js': 3 },
  index: 1,
  indexDeps: { './z.js': 4, './w.js': 3 } }
[]

Environment:
Windows 8.1 x64
Node.js v0.10.33
Browserify 8.0.2
factor-bundle 2.3.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions