Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Support CommonJS #566

Closed
bendrucker opened this issue Feb 26, 2015 · 5 comments
Closed

Support CommonJS #566

bendrucker opened this issue Feb 26, 2015 · 5 comments

Comments

@bendrucker
Copy link
Contributor

Some upstanding citizen who may or may not be me shipped CommonJS support for Angular in 1.3.14 and 1.4 beta. So that means you can require('angular'), but also this:

require('angular').module('myApp', [
  require('angular-messages')
]);

That's because require('angular-messages') === 'ngMessages'. Requiring the code registers the module, but the actual return value is the string name of the module.

Here's how to do this without actually using browserify to build AngularFire:

  1. Change main in package.json to index.js
  2. Create index.js at the project root
  3. Populate index.js with the following:
require('./dist/angularfire.js');
module.exports = 'firebase';

This is exactly how Angular does it for all its various angular-* repos.

Full discussion where this was discussed and my way was blessed in angular/angular.js#10732

@jamestalmage
Copy link
Contributor

lol

screenshot 2015-02-26 13 16 17

@jwngr
Copy link

jwngr commented Feb 26, 2015

Man on a mission.

@bendrucker
Copy link
Contributor Author

I had to write bash for this. Shit got real: angular/bower-angular-i18n@8e4b78d

Also:

holy mother of files

@bendrucker
Copy link
Contributor Author

Merged in #567

@jwngr
Copy link

jwngr commented Feb 26, 2015

Haha, thanks @bendrucker; nice addition! I added it as a feature for our running changelog for 1.0.0.

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

No branches or pull requests

3 participants