Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Require.js #72

Open
bradleyayers opened this issue Mar 5, 2015 · 2 comments
Open

Doesn't work with Require.js #72

bradleyayers opened this issue Mar 5, 2015 · 2 comments

Comments

@bradleyayers
Copy link

The bower distributed delorean does not work with Require.js

First problem is require('events').EventEmitter:

module.exports = requirements = {
  // DeLorean uses **Node.js native EventEmitter** for event emittion
  EventEmitter: require('events').EventEmitter,
  // and **es6-promise** for Deferred object management.
  Promise: require('es6-promise').Promise
};

But the module is defined as:

module.exports = EventEmitter

So I think in the injector it should just be require('event') right?

Second problem is in the injector:

// This library needs to work for Browserify and also standalone.
// If DeLorean is defined, it means it's called from the browser, not
// the browserify.
if (typeof DeLorean !== 'undefined') {
  for (var requirement in requirements) {
    DeLorean.Flux.define(requirement, requirements[requirement]);
  }
}

But when used in the browser with Require.js, DeLorean is undefined because:

if (typeof define === 'function' && define.amd) {
  define([], function () {
    return DeLorean;
  });
} else {
  window.DeLorean = DeLorean;
}
@bradleyayers
Copy link
Author

I also tried building it with browserify, but get the same problem when using the build version in the browser.

@bradleyayers
Copy link
Author

I can work around it by just use delorean.js directly (without requirements.js) from the npm distribution (because it's not yet browserified). I then define my own module delorean.flux that does the DeLorean.Flux.define setup:

define(["delorean", "eventemitter2", "es6-promise"], function (delorean, EventEmitter2, Promise) {
  delorean.Flux.define("EventEmitter", EventEmitter2);
  delorean.Flux.define("Promise", Promise);
  return delorean.Flux;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant