Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Globals #386

Closed
wants to merge 3 commits into from

3 participants

@amiuhle

Option to add provide custom global process and Buffer implementations, currently only via grunt-browserify:

browserify: {
  bundle: {
    src: [],
    require: ['mongodb', 'tcp_wrap-chromeify'],
    dest: 'app/scripts/vendor/bundle.js',
    ignore: 'node_modules/browser-resolve/node_modules/buffer-browserify/index.js',
    options: {
      globals: {
        process: 'browser-resolve/builtin/process',
        Buffer: 'buffer-browserify'
      }
    }
  }
}
@dominictarr
Collaborator

does this depend on this pull request: defunctzombie/node-browser-resolve#17

I can see that you have changed the package.json, but I can't see anything regarding globals in it.

@amiuhle

@dominictarr No, it doesn't - sorry, that probably shouldn't even be part of the pull request. Must have slipped in during development.

@dominictarr
Collaborator

Can this be used via the api? (without grunt?)
can you post an example using it without grunt (or even better - add a readme section to your pull request)

note, I'm not the module maintainer, but I think this is what @substack would say if he was less busy.

@substack
Owner

You can currently override the buffer implementation using opts.builtins. It would be best to get a separate pull request for just setting process to a custom thing.

@substack substack closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2013
  1. @amiuhle

    Dynamic globals

    amiuhle authored
Commits on Apr 22, 2013
  1. @amiuhle
Commits on Apr 24, 2013
  1. @amiuhle

    Removed changes to package.json

    amiuhle authored
    This reverts commit 7d907fd.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 2 deletions.
  1. +12 −2 index.js
View
14 index.js
@@ -131,12 +131,22 @@ Browserify.prototype.bundle = function (opts, cb) {
});
return tr;
}
-
+
+ opts.globals = opts.globals || {};
+ var globals = {};
+ for(var key in opts.globals) {
+ globals[key] = {
+ id: opts.globals[key],
+ file: self._mapped[key]
+ }
+ }
+
var d = self.deps(opts);
var g = opts.detectGlobals || opts.insertGlobals
? insertGlobals(self.files, {
resolve: self._resolve.bind(self),
- always: opts.insertGlobals
+ always: opts.insertGlobals,
+ globals: globals
})
: through()
;
Something went wrong with that request. Please try again.