Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jasonmit/ember-cli-moment-shim
ember-cli shim for momentjs
https://github.com/jasonmit/ember-cli-moment-shim
ember-addon ember-moment moment momentjs
Last synced: 4 days ago
JSON representation
ember-cli shim for momentjs
- Host: GitHub
- URL: https://github.com/jasonmit/ember-cli-moment-shim
- Owner: jasonmit
- License: mit
- Created: 2014-10-16T21:43:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-30T07:56:35.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T11:08:04.702Z (9 months ago)
- Topics: ember-addon, ember-moment, moment, momentjs
- Language: JavaScript
- Homepage:
- Size: 670 KB
- Stars: 33
- Watchers: 4
- Forks: 59
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-cli-moment-shim
As of [ember-moment v10](https://github.com/adopted-ember-addons/ember-moment/blob/master/CHANGELOG.md#1000) this library is no longer required to import moment, moment-timezone, or configure any of the build options. Instuctions for bundling [locale and timezone data](https://github.com/adopted-ember-addons/ember-moment#controlling-locale-and-timezone-data) can be found in the `ember-moment` readme.
# For posterity the original documentation
ember-cli ES6 module shim for [momentjs](https://momentjs.com) and [moment timezone](https://momentjs.com/timezone/) within your Ember applications. It will also conditionally bundle in specific locale/timezone data for those concerned about payload size.
## Usage
* `ember install ember-cli-moment-shim`
```js
import moment from 'moment';
```## Features
* ES6 accessible module for moment
* Trim your build sizes by bundling locale & timezone data through simple configuration
* FastBoot support## Enabling moment-timezone
```js
// config/environment.js
module.exports = function(environment) {
return {
moment: {
// Options:
// 'all' - all years, all timezones
// 'subset' - subset of the timezone data to cover 2010-2020 (or 2012-2022 as of 0.5.12). all timezones.
// 'none' - no data, just timezone API
includeTimezone: 'all'
}
};
}
```## i18n support
### Cherry pick locales (optimal)
```js
// config/environment.js
module.exports = function(environment) {
return {
moment: {
// To cherry-pick specific locale support into your application.
// Full list of locales: https://github.com/moment/moment/tree/master/locale
includeLocales: ['es', 'fr-ca']
}
};
```*NOTE: English is bundled automatically – no need to add `en` in `includeLocales`*
### Include all locales
```js
// config/environment.js
module.exports = function(environment) {
return {
moment: {
includeLocales: true
}
};
```### Configure default runtime locale
```js
// app/routes/applicaton.js
import moment from 'moment';export default Ember.Route.extend({
beforeModel() {
// sets the application locale to Spanish
moment.locale('es');
}
});
```### Write all locales to a folder that is relative to `dist`
```js
// config/environment.js
module.exports = function(environment) {
return {
moment: {
// This will output _all_ locale scripts to assets/moment-locales
// this option does not respect includeLocales
localeOutputPath: 'assets/moment-locales'
}
};
```The feature set for i18n support within moment can be found here: http://momentjs.com/docs/#/i18n/
## License
ember-cli-moment-shim shims is [MIT Licensed](https://github.com/jasonmit/ember-cli-moment-shim/blob/master/LICENSE.md).
[npm]: https://www.npmjs.org/package/ember-cli-moment-shim
[npm-badge]: https://img.shields.io/npm/v/ember-cli-moment-shim.svg?style=flat-square