ef4 / ember-browserify

ember-cli addon for easily loading CommonJS packages from npm via browserify.
MIT License
172 stars 28 forks source link

Load custom npm files #43

Closed SamiSammour closed 8 years ago

SamiSammour commented 8 years ago

I am using ember-browserify to work with momentjs in my ember app and I need to specify the locale for moment but I couldn't because the required locale files are not loaded. is there any way that I can tell browserify to load these files? they are located in the 'locale' folder inside moment nodes_module folder.

asakusuma commented 8 years ago

Are these locale files somehow available if you require('moment') in a node app?

Your only recourse for customizing browserify behavior is through the config.

SamiSammour commented 8 years ago

As they say on their website Loading locales in NodeJS once you call moment.locale('fr'); the locale is loaded. but when I tried it in my ember application it's not loaded and I get the text in English not in French. My function looks like this:

import moment from 'npm:moment';

export function dateRelative(params/*, hash*/) {
  var date = params[0] || new Date();
  return moment(date).locale('fr').fromNow();
}
louy commented 8 years ago

I think you should be able to solve it by importing the locale manually. Apparently it's not included in the build as it's being required at a late stage.

Just add

import momentFR from 'npm:moment/locale/fr';

to your app.js file.

stefanpenner commented 8 years ago

Just add

import momentFR from 'npm:moment/locale/fr'; to your app.js file.

^