urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

Main attribute in package.json #257

Closed okayawright closed 7 years ago

okayawright commented 8 years ago

Can you please add the attribute: "main": "angular-momentjs.js" in your package.json so that some modules like node-resolve for Gulp https://github.com/substack/node-resolve can find the entry point in your component. Cheers.

urish commented 8 years ago

yes, can you please send a PR for that?

thanks, Uri

On Sun, Jul 3, 2016 at 5:04 PM, okay_awright notifications@github.com wrote:

Can you please add the attribute: "main": "angular-momentjs.js" in your package.json so that some modules like node-resolve for Gulp https://github.com/substack/node-resolve can find the entry point in your component. Cheers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/urish/angular-moment/issues/257, or mute the thread https://github.com/notifications/unsubscribe/AA2dnn3TA_7iXhThvkcmZh0gwtEHIKDUks5qR8-GgaJpZM4JD4rA .

chyzwar commented 8 years ago

Imo better will be to follow with what other are doing.

ngAria, ngMaterial, ngAnimate all have index.js as main like:

require('./angular-animate');
module.exports = 'ngAnimate';

This will initalise module and provide a name to be used in module definition like:

import ngAnimate from 'angular-animate';

angular.module('myApp' , [
 ngAnimate
]);

This shuld also work for commonjs, es6, browserity.

urish commented 7 years ago

The package.json entry is there

chyzwar commented 7 years ago

But it do not export name of module. There no simple way to use this module with clj or ES modules. Angular1 have this silly convention of adding modules by name and hoping that they are available in runtime. When used with with ESModules I would like to:

import ngMoment from 'angular-moment';

angular.module('myApp', [
    ngMoment
]);

I pointed to ngAnimate solution that is widely used in core. For CLJ and ES Modules what is needed is name of module not module itself.

I can see in release notes that for AMD module name is exported, it would be also the case for CJS?