browserify / factor-bundle

factor browser-pack bundles into common shared bundles
Other
402 stars 27 forks source link

Require("react") returns a weird object. #17

Closed DjebbZ closed 10 years ago

DjebbZ commented 10 years ago

Hi,

I wanted to use factor-bundle because it's awesome, but it doesn't work. The require("react") doesn't return the expected React object but this :

{
    argv: [],
    browser: true,
    env: Object: {},
    title: "browser",
    binding: function(),
    chdir: function(),
    cwd: function(),
    nextTick: nextTick(fn)
}

Here is the build command issued : browserify index1.js index2.js -p [ factor-bundle -o build1.js -o build2.js ] -o common.js

When I try "manually" without factor-bundle like the following, it works fine : browserify -r react > common.js && browserify -x react index1.js > build1.js

I noticed in the build files that when using Browserify alone the "id" of the module was an external string like "X9WGS" whereas when using factor-bundle the id was a number above 5000. Note sure this detail is relevant though.

Tested several times with the latest factor-bundle 0.2.2, all these Browserify versions : 3.28.2, 3.29.1, 3.30.1, and the latest React (0.9.0-rc1). Note : React is coded as node modules and the React team uses Browserify (+ Grunt, but not factor-bundle) for their build.

terinjokes commented 10 years ago

I think this is related to #13.

AndrewIngram commented 10 years ago

I've having similar problems, in the browser console in my entry point scripts:

require('react')
Object {injection: Object, eventNameDispatchConfigs: Object, registrationNameModules: Object, putListener: function, getListener: function…}
__getListenerBank: function () {
__purge: function () {
deleteAllListeners: function (id) {
deleteListener: function (id, registrationName) {
enqueueEvents: function (events) {
eventNameDispatchConfigs: Object
extractEvents: function (
getListener: function (id, registrationName) {
injection: Object
processEventQueue: function () {
putListener: function (id, registrationName, listener) {
registrationNameModules: Object
__proto__: Object

require('backbone')
function (props, children) {
      var instance = new Constructor();
      instance.construct.apply(instance, arguments);
      return instance;
    } 

If I use browserify({fullPaths: true}); I instead get Uncaught Error: Cannot find module '22'

terinjokes commented 10 years ago

If you upgrade to the latest versions of browserify and factor-bundle, this issue should be resolved.

ghost commented 10 years ago

Pretty sure this has been fixed. Closing.