Code Monkey home page Code Monkey logo

ember-cli-moment-shim's Introduction

ember-cli-moment-shim

As of ember-moment v10 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 can be found in the ember-moment readme.

For posterity the original documentation

ember-cli ES6 module shim for momentjs and moment 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
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

// 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)

// 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

// config/environment.js
module.exports = function(environment) {
  return {
    moment: {
      includeLocales: true
    }
  };

Configure default runtime locale

// 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

// 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.

ember-cli-moment-shim's People

Contributors

abuiles avatar bartheleway avatar dnegstad avatar greenkeeperio-bot avatar jacefarm avatar jasonmit avatar jherdman avatar jmurphyau avatar jrjohnson avatar karlbecker avatar kybishop avatar loganrosen avatar nathanhammond avatar ncastro-nypr avatar rlivsey avatar seanpdoyle avatar turbo87 avatar wozny1989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-cli-moment-shim's Issues

Moment range integration

๐Ÿ‘‹ Wondering if you'd accept a PR for moment-range integration?

Ember CLI Moment Range exists, but is not maintained, uses a bower package app import and isn't compatible with ember-moment & ember-cli-moment-shim.

The moment-range library is well maintained and would be conditionally imported via an includeRange flag in config/environment.js.

Bug found: can't define any configurations

Environment:

  • Windows 10 Home Edition (win32 x64)
  • node.js v4.2.2
  • npm v2.14.7
  • ember-cli v1.13.8

Descriptions:

After install ember-cli-moment-shim (or upgrade, I've tried a lot of times), if some custom configuration defined, ember serve will not success. For examples:

// config/environment.js
moment: {
  includeTimezone: 'all'
}

will causes:

ENOENT: no such file or directory, symlink 'C:\Users\Yu\Code\cloud.mei1.com\bower_components\moment-timezone\builds\mome
nt-timezone-with-data.min.js' -> 'C:\Users\Yu\Code\cloud.mei1.com\tmp\funnel-output_path-ruvaKEVz.tmp\moment-timezone\tz
.js'
Error: ENOENT: no such file or directory, symlink 'C:\Users\Yu\Code\cloud.mei1.com\bower_components\moment-timezone\buil
ds\moment-timezone-with-data.min.js' -> 'C:\Users\Yu\Code\cloud.mei1.com\tmp\funnel-output_path-ruvaKEVz.tmp\moment-time
zone\tz.js'
    at Error (native)
    at Object.fs.symlinkSync (fs.js:897:18)
    at symlinkWindows (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funnel\n
ode_modules\symlink-or-copy\index.js:90:16)
    at Function.symlinkOrCopySync [as sync] (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_mod
ules\broccoli-funnel\node_modules\symlink-or-copy\index.js:56:5)
    at Funnel._copy (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funnel\ind
ex.js:394:19)
    at Funnel.processFile (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funn
el\index.js:377:8)
    at Funnel.applyPatch [as _applyPatch] (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modul
es\broccoli-funnel\index.js:295:12)
    at Funnel.<anonymous> (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funn
el\index.js:247:10)
    at Array.forEach (native)
    at Funnel.processFilters (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-f
unnel\index.js:246:9)

and

// config/environment.js
moment: {
  includeLocales: ['zh-cn']
}

will causes:

ENOENT: no such file or directory, mkdir 'C:\Users\Yu\Code\cloud.mei1.com\tmp\funnel-output_path-q5DIRweY.tmp\moment\loc
ales'
Error: ENOENT: no such file or directory, mkdir 'C:\Users\Yu\Code\cloud.mei1.com\tmp\funnel-output_path-q5DIRweY.tmp\mom
ent\locales'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:794:18)
    at Funnel.applyPatch [as _applyPatch] (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modul
es\broccoli-funnel\index.js:288:10)
    at Funnel.<anonymous> (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funn
el\index.js:247:10)
    at Array.forEach (native)
    at Funnel.processFilters (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-f
unnel\index.js:246:9)
    at Funnel.build (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funnel\ind
ex.js:168:10)
    at C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\broccoli-funnel\node_modules\broc
coli-plugin\read_compat.js:61:34
    at lib$rsvp$$internal$$tryCatch (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modules\bro
ccoli-funnel\node_modules\broccoli-plugin\node_modules\promise-map-series\node_modules\rsvp\dist\rsvp.js:493:16)
    at lib$rsvp$$internal$$invokeCallback (C:\Users\Yu\Code\cloud.mei1.com\node_modules\ember-cli-moment-shim\node_modul
es\broccoli-funnel\node_modules\broccoli-plugin\node_modules\promise-map-series\node_modules\rsvp\dist\rsvp.js:505:17)

but if set includeLocales: true will be ok.

All these settings above will all be fine under Mac OS X (same project), only errors occur under windows, I've tested this on windows 7 Ultimate Edition & windows 8/10 Home Edition.

How to use moment-timezone?

I have enabled moment-timezone in config/environment.js
But it does not work for me.

import Ember from 'ember';
import moment from 'moment';

export default Ember.Component.extend({
  actions: {
    getTimezone(){
      return moment.tz.guess();
    }
  }
});

I have got the following error:
Uncaught TypeError: Cannot read property 'guess' of undefined

Cherry picking locales does not work

I'm trying to load in spanish and english locales, but this config is not picked up. When I set the locale with moment.locale("es") and check again with moment.locale() the locale is still set to "en"

config/environment.js

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'tracker-plugin-panel',
    environment: environment,
    baseURL: '/',
    locationType: 'hash',
    moment: {
      // To cherry-pick specific locale support into your application.
      // Full list of locales: https://github.com/moment/moment/tree/2.10.3/locale
      includeLocales: ['es', 'en']
    },
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },
//etc

Upgrade to ember-cli-babel@^6.0.0

This addon is outdated with the recent Ember versions

[email protected]:
  version "3.3.3"
  resolved "https://registry.yarnpkg.com/ember-cli-moment-shim/-/ember-cli-moment-shim-3.3.3.tgz#f0609c6ff606287c3eeee717163310331e0e9397"
  dependencies:
    broccoli-funnel "^1.1.0"
    broccoli-merge-trees "^2.0.0"
    broccoli-source "^1.1.0"
    broccoli-stew "^1.4.0"
    chalk "^1.1.3"
    ember-cli-babel "^5.1.7"
    ember-cli-import-polyfill "^0.2.0"
    exists-sync "^0.0.4"
    lodash.defaults "^4.2.0"
    moment "^2.18.1"
    moment-timezone "~0.5.11"
$> ember -v

ember-cli: 2.14.1
node: 8.2.1
os: darwin x64

IncludedLocales is changing default locale

If i try and cherry pick my locale(s) as described in the documentation.

        moment: {
            includeLocales: ['es'],
        }

The default locale is set to 'es' not 'en'.

If i switch it to

        moment: {
            includeLocales: true,
        }

Then 'en' becomes the default again.

apparently

 includeLocales: ['en', 'es']

is not a valid option either.

Suggestions?

includeLocales: true stopped working in 3.8.0

After updating from 3.5.0 to 3.8.0, includeLocales: true stopped working with the error:

ENOENT: no such file or directory, open '/tmp/broccoli-7755BBEmsOOPNspH/out-297-broccoli_debug_debug_2_vendor_js/vendor/moment/moment-with-locales.js'

Removing the line makes the build work again, however then it does not include all locales. It works if I manually specify locales.

This happens in an addon's dummy app.

Cannot overwrite `moment.now` from tests

In my application I have to group items with dates into buckets "Today", "Tomorrow", "Next Week", etc.. While writing tests for this functionality, I realized the tests would fail if today was on a boundary. For example, given the week starts Monday as per isoWeek, running the tests on Sunday would put an item with tomorrow's date into "Next Week" rather than "Tomorrow", causing the tests that look for "Tomorrow" to fail.

The way I've solved this in other apps that use moment is to overwrite moment.now to set "today" to a known date for various tests. However, with ember-moment (which uses this shim), it seems this doesn't work.

I've created an example app to demonstrate the issue (note the failing Travis tests).

Is this something fixable? Is there a recommended workaround?

Funnel: Expected Broccoli node, got undefined for inputNodes[0]

I am creating a ember addon. When adding ember-cli-moment-shim to dependencies in package.json I am getting an error:

TypeError: Funnel: Expected Broccoli node, got undefined for inputNodes[0]
    at Funnel.Plugin (node_modules/broccoli-plugin/index.js:23:13)
    at new Funnel (node_modules/ember-cli-moment-shim/node_modules/broccoli-funnel/index.js:57:10)
    at Funnel (node_modules/ember-cli-moment-shim/node_modules/broccoli-funnel/index.js:54:43)
    at Class.treeForVendor (node_modules/ember-cli-moment-shim/index.js:146:7)
    at Class._treeFor (node_modules/ember-cli/lib/models/addon.js:557:33)
    at Class.treeFor (node_modules/ember-cli/lib/models/addon.js:517:21)
    at addons.reduce (node_modules/ember-cli/lib/models/addon.js:384:26)
    at Array.reduce (<anonymous>)
    at Class.eachAddonInvoke (node_modules/ember-cli/lib/models/addon.js:381:24)
    at Class.treeFor (node_modules/ember-cli/lib/models/addon.js:516:22)

The error is caused by this.momentNode being undefined in index.js:146

  treeForVendor(vendorTree) {
    let trees = [];
    let options = this._options;

    if (vendorTree) {
      trees.push(vendorTree);
    }

    trees.push(
      funnel(this.momentNode, {
        destDir: 'moment',

When testing this I am getting undefined for both this._options and this.momentNode when checking them outside of included where they are assigned. included is called before treeForVendor. Any ideas what is causing this error ?

Ember-cli upgrade results in Cannot read property 'momentPath' of undefined

Just upgraded ember-cli to the latest and my project is failing w/

version: 1.13.12
Cannot read property 'momentPath' of undefined
TypeError: Cannot read property 'momentPath' of undefined
    at Class.module.exports.treeForVendor ([MY PROJECT PATH]/node_modules/ember-cli-moment-shim/index.js:93:34)

The line that is failing in your index.js is:


  treeForVendor: function(vendorTree) {
    var trees = [];
    var options = this.options;

    if (vendorTree) {
      trees.push(vendorTree);
    }

    trees.push(new Funnel(options.momentPath, {
      destDir: 'moment',
      include: [new RegExp(/\.js$/)],
      exclude: ['tests', 'ender', 'package'].map(function(key) {
        return new RegExp(key + '\.js$');
      })
    }));

Any ideas?

QUEST - Make Ember CLI Moment Shim Optional

Ember CLI Moment Shim was built as just that: a shim to be able to import moment from 'moment';.
It has served this purpose great but we are on the horizon of being able to just import moment without any extra fanfare or shim.
This quest serves as a place to list known community addons that have a hard dependency for ember-cli-moment-shim and a place to log progress of helping to remove this dependency.


Some strategies for making ember-cli-moment-shim optional for addons:

  1. Move ember-cli-moment-shim from dependencies to devDependencies
  2. Install ember-cli-moment-shim in the addon blueprint (ideally only installing shims for host apps that do not have ember-auto-import or packager)

Things to still figure out:

  1. List of addons that are depending on ember-cli-moment-shim in dependencies
  2. How to determine if a shim is needed
  3. Timezone configuration without shim?
  4. Does packager and ember-auto-import gracefully handle development/production imports?

Fastboot assets in build in non-fastboot app

With 3.4.0 of this addon I'm seeing these files in my build even though I'm not in a fasboot app, is this expected?

  • dist/moment/fastboot-moment.js
  • dist/moment/fastboot-moment-timezone.js

moment.tz is undefined

Might be having a silly 'moment' here, but with a fresh ember-cli project
and ENV.moment.includeTimezone = 'all'

moment.tz === undefined

ember-cli: 2.14.0
node: 6.9.1
os: darwin x64

Advantages over ember-auto-import?

I am currently using this shim in a project but am trying to migrate to using ember-auto-import. Can you help me understand how this differs? For example, would this cause me to lose fastboot support and/or the ability to trim the locale data?

Add FastBoot test support

Fastboot test support is in its infancy, but some exploring and if the path forward is clear enough.. then implement fastboot test support.

Please push tags with NPM releases

First off, We love the library - thanks!

In the future - if possible - can you please push the npm release tags to github? It is much more difficult to examine changes between versions without tags.

Using timezone in environment.js crashes fastboot

Apologies if it's against wrong repo. I'm not yet sure how to distinguish between fastboot and addon errors.

Steps to reproduce:

  1. Add:
    moment: {
      includeTimezone: '2010-2020'
    }

to environment.js:

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'moment-fastboot-example',
    environment: environment,
    rootURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },
    moment: {
      includeTimezone: '2010-2020'
    }
  };
..
  1. Run NODE_DEBUG=fs ember fastboot --serve-assets
โžœ  moment-fastboot-example git:(master) โœ— NODE_DEBUG=fs ember fastboot --serve-assets
Installing FastBoot npm dependencies

Build successful - 5007ms.

Slowest Trees                                 | Total               
----------------------------------------------+---------------------
Addon#treeFor (ember-cli-release - addon)     | 499ms               
Funnel: Addon JS                              | 451ms               
SourceMapConcat: Concat: Vendor /assets/ve... | 275ms               
SourceMapConcat: Concat: Vendor /assets/ve... | 272ms               

Slowest Trees (cumulative)                    | Total (avg)         
----------------------------------------------+---------------------
Babel (30)                                    | 1060ms (35 ms)      
Funnel: Addon JS (18)                         | 555ms (30 ms)       
SourceMapConcat: Concat: Vendor /asset... (2) | 548ms (274 ms)      
Addon#treeFor (ember-cli-release - addon) (2) | 500ms (250 ms)      

fs.js:88
        throw backtrace;
        ^

Error: ENOTEMPTY: directory not empty, rmdir '/Users/gandalf/hacking/fastboot/moment-fastboot-example/dist/node_modules/moment-timezone/'
    at rethrow (fs.js:83:21)
    at maybeCallback (fs.js:101:42)
    at Object.fs.rmdir (fs.js:871:14)
    at TreeSync.<anonymous> (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/tree-sync/index.js:79:19)
    at Array.forEach (native)
    at TreeSync.sync (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/tree-sync/index.js:50:14)
    at CoreObject.module.exports.Task.extend.copyToOutputPath (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/ember-cli/lib/models/builder.js:173:10)
    at /Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/ember-cli/lib/models/builder.js:187:21
    at lib$rsvp$$internal$$tryCatch (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/rsvp/dist/rsvp.js:493:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/gandalf/hacking/fastboot/moment-fastboot-example/node_modules/rsvp/dist/rsvp.js:505:17)

This error persists even if I remove the above lines in the environment.js

Repo with the above problem: https://github.com/gandalfar/moment-fastboot-example

โžœ  moment-fastboot-example git:(master) ember -v
ember-cli: 2.7.0
node: 6.2.1
os: darwin x64

Fastboot rc support

Fastboot changed a bit in the rc1 and ember-cli-moment-shim will no longer work until we adopt the new build API.

[Feature request] support for locales

It seems there is no option (yet) to easily import/use the locales which come with moment with this shim without adding them to the brocfile/ember-cli-build.

Fastboot support

Currently if you run under Fastboot and have moment-timezone enabled, an error is thrown on build because moment-timezone notices it's running under NPM (require is present) and attempts to require moment, which fails because obviously neither library is present in node_modules:

Built project successfully. Stored in "fastboot-dist".
Installing FastBoot npm dependencies
Could not find module `moment` imported from `(require)`
Error: Could not find module `moment` imported from `(require)`
    at missingModule (/Users/rlivsey/Development/experiments/fastboot-test/fastboot-dist/assets/vendor/loader/loader.js:164:1)
    at findModule (/Users/rlivsey/Development/experiments/fastboot-test/fastboot-dist/assets/vendor/loader/loader.js:179:1)
    at requireModule (/Users/rlivsey/Development/experiments/fastboot-test/fastboot-dist/assets/vendor/loader/loader.js:168:1)
    at /Users/rlivsey/Development/experiments/fastboot-test/fastboot-dist/assets/vendor/moment-timezone/tz.js:6:1
    at /Users/rlivsey/Development/experiments/fastboot-test/fastboot-dist/assets/vendor/moment-timezone/tz.js:6:1

I wonder if instead of using Bower, this addon should instead use NPM for the moment and moment-timezone dependencies and then it might work for both normal and Fastboot operation?

I should have some time this week to spike on this if you think this is a valid direction to go in, or if you have any other ideas for how best to get Fastboot support working.

3.5.1 breaks build

After updating from 3.5.0 to 3.5.1, my build is not working anymore.

I get this error:

Build Error (Concat)

ENOENT: no such file or directory, open 'C:\...\tmp\source_map_concat-input_base_path-phKRngPs.tmp\vendor\moment-timezone\tz.js'

Dowgrading back to 3.5.0 fixes it for me.

I'm not entirely sure, I found this commit, which says "BREAKING": 63894b9

But it was released as a patch version? Do I need to change anything?

I found this issue in a lazy loaded engine, on Ember 2.18.

ember-twiddle has issues consuming ember-cli-moment-shim

Installed packages for tooling via npm.
installing ember-moment
  install addon ember-cli-moment-shim
Installed packages for tooling via npm.
installing ember-cli-moment-shim
Installed addon package.
Installed addon package.
Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Path must be a string. Received { development: 'vendor/moment/moment.js',
  production: 'vendor/moment/min/moment.min.js' }
TypeError: Path must be a string. Received { development: 'vendor/moment/moment.js',
  production: 'vendor/moment/min/moment.min.js' }
    at assertPath (path.js:7:11)
    at Object.extname (path.js:1431:5)
    at StubApp.import (/addon-builder/ember-cli-build.js:26:18)
    at Class.importBrowserDependencies (/addon-builder/node_modules/ember-cli-moment-shim/index.js:74:17)
    at Class.included (/addon-builder/node_modules/ember-cli-moment-shim/index.js:30:12)
    at Class.superWrapper [as included] (/addon-builder/node_modules/core-object/lib/assign-properties.js:32:18)
    at StubApp.<anonymous> (/addon-builder/node_modules/ember-cli/lib/broccoli/ember-app.js:469:15)
    at Array.filter (native)
    at StubApp.EmberApp._notifyAddonIncluded (/addon-builder/node_modules/ember-cli/lib/broccoli/ember-app.js:464:45)
    at StubApp.EmberApp (/addon-builder/node_modules/ember-cli/lib/broccoli/ember-app.js:137:8)

can you increment major instead of minor for 3.8.0 release

since there is a babel version change in v3.8.0 instead of minor increment can you do major increment.

the problem I am facing is I am using ember-power-calendar which is having dependency of ember-cli-moment-shim i am using babel 5 but due to your recent release and increment of babel version it is causing problem in my addon.

or else can you guide me how to lock ember-cli-moment-shim dependency

Months translation missing for Russian locale

I have weird behaviour when displaying a date picker for Russian locale (ru).
I'm using ember-pikaday add-on and defined the initializer as it was suggested:

#app/initializers/setup-pikaday-i18n.js

import Ember from 'ember';
import moment from 'moment';

export default {
  name: 'setup-pikaday-i18n',
  initialize: function(application) {
    var i18n = Ember.Object.extend({
      months: moment.localeData()._months,
      weekdays: moment.localeData()._weekdays,
      weekdaysShort: moment.localeData()._weekdaysShort
    });

    application.register('pikaday-i18n:main', i18n, { singleton: true });
    application.inject('component:pikaday-input', 'i18n', 'pikaday-i18n:main');
  }
};

It works fine for all other languages but not for Russian.
The line months: moment.localeData()._months returns correctly the months

January,February,March,April,May,June,July,August,September,October,November,December

the same for translated versions of other languages but not for Russian where it sends [Object object].

Here is how the failing display looks like:
Screenshot 2019-04-09 at 16 43 29

I also enabled all the locales in config/environment.js:

...
moment: {
      includeLocales: true
    }

I grab the User locale in application.js route as follows:

#routes/application.js

export default Route.extend(ApplicationRouteMixin, {
  currentUser: service(),
  intl: service(),

  beforeModel() {
    let locale = this.figureOutLocale();
    this.intl.setLocale(locale);
    moment.locale(locale);
    console.log('months: ' + moment.localeData()._months);
    
    return this._loadCurrentUser();
  },

  sessionAuthenticated() {
    this._super(...arguments);
    this._loadCurrentUser();
  },

  _loadCurrentUser() {
    return this.get('currentUser').loadCurrentUser().catch(() => this.get('session').invalidate());
  },

  figureOutLocale() {
    let locale = this.calculateLocale(this.intl.get('locales'));
    return locale;
  },

  calculateLocale(locales) {
    const userLanguage = navigator.languages[0] || navigator.language || navigator.userLanguage;    
    let matchedLanguage = userLanguage.match(/\w{2}/)[0].toLowerCase();

    return  locales.includes(matchedLanguage) ? matchedLanguage : 'en';
  }
});
```

What's wrong with that? Thank you.

Turn on travis ci

Configuration should be good to go.. just need to create a project in travis

Path or pattern "bower_components/ember-cli-moment-shim/moment-shim.js" did not match any files

I've got this bug when I execute ember s:

Path or pattern "bower_components/ember-cli-moment-shim/moment-shim.js" did not match any files
Error: Path or pattern "bower_components/ember-cli-moment-shim/moment-shim.js" did not match any files
    at Object.multiGlob (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/broccoli-kitchen-sink-helpers/index.js:203:13)
    at Class.module.exports.CachingWriter.extend.addFiles (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/broccoli-sourcemap-concat/concat-with-maps.js:74:13)
    at Class.module.exports.CachingWriter.extend.updateCache (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/broccoli-sourcemap-concat/concat-with-maps.js:52:12)
    at /Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/broccoli-sourcemap-concat/node_modules/broccoli-caching-writer/index.js:92:34
    at lib$rsvp$$internal$$tryCatch (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:489:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:501:17)
    at lib$rsvp$$internal$$publish (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:472:11)
    at lib$rsvp$asap$$flush (/Users/jeancreuzedeschatelliers/Developpement/Projets/contactsmanagement/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1290:9)
    at process._tickCallback (node.js:355:11)

Fastboot 1.1.3 - Cannot find module 'moment'

Iโ€™m running into a couple of dependency / module issues with this library when running the fastboot-app-server locally. When I have includeTimezone: 'all' listed in my environment file, build the ember app, and then start my node server using PORT=8000 node server.js I get the following error:

There was an error running your app in fastboot. More info about the error:
 Error: Cannot find module 'moment-timezone'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.require (/Users/erichubbell/Sites/joyrides/fastboot-app-server/node_modules/fastboot/src/ember-app.js:130:18)
    at Module.callback (/Users/erichubbell/Sites/startup-playbooks/startup-playbooks-web/dist/moment/fastboot-moment-timezone.js:4:34)

When I remove includeTimezone: 'all' from my environment file, I get the following:

There was an error running your app in fastboot. More info about the error:
 Error: Cannot find module 'moment'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.require (/Users/erichubbell/Sites/joyrides/fastboot-app-server/node_modules/fastboot/src/ember-app.js:130:18)
    at Module.callback (/Users/erichubbell/Sites/startup-playbooks/startup-playbooks-web/dist/moment/fastboot-moment.js:4:34)

I've tried several different version combinations of ember-cli-fastboot, ember-moment, and ember-cli-moment-shim in an attempt to fix this. I've also tried whitelisting those libraries and including them as dependencies in my package.json file. I also see the dist/moment directory with fastboot-moment-timezone.js and fastboot-moment.js files.

If I remove import moment from 'moment'; and any mentions of moment() from the component that's displayed on the homepage of my app - Fastboot loads fine. It's only when I add the import statement or call to moment() that Fastboot breaks.

I've read over the ember-fastboot docs as they pertain to dependencies pretty thoroughly and am unsure what's causing this and / or how to troubleshoot further. Any thoughts on how to fix this Or, does anyone know a working combination of ember-source, ember-cli-fastboot, and ember-cli-moment-shim? Here's my current package.json file for reference and thanks in advance!

{
  "name": "startup-playbooks-web",
  "version": "0.0.0",
  "private": true,
  "description": "Small description for startup-playbooks-web goes here",
  "license": "MIT",
  "author": "",
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "repository": "",
  "scripts": {
    "build": "ember build",
    "lint:js": "eslint ./*.js app config lib server tests",
    "start": "ember serve",
    "test": "ember test"
  },
  "devDependencies": {
    "bootstrap": "^4.0.0",
    "broccoli-asset-rev": "^2.4.5",
    "ember-ajax": "^3.0.0",
    "ember-cli": "~3.1.2",
    "ember-cli-app-version": "^3.0.0",
    "ember-cli-babel": "^6.6.0",
    "ember-cli-bootstrap-4": "^0.5.6",
    "ember-cli-dependency-checker": "^2.0.0",
    "ember-cli-eslint": "^4.2.1",
    "ember-cli-fastboot": "1.1.3",
    "ember-cli-flash": "^1.6.3",
    "ember-cli-google-fonts": "^2.16.2",
    "ember-cli-head": "^0.4.0",
    "ember-cli-htmlbars": "^2.0.1",
    "ember-cli-htmlbars-inline-precompile": "^1.0.0",
    "ember-cli-inject-live-reload": "^1.4.1",
    "ember-cli-moment-shim": "^3.5.0",
    "ember-cli-qunit": "^4.1.1",
    "ember-cli-sass": "^7.1.7",
    "ember-cli-shims": "^1.2.0",
    "ember-cli-sri": "^2.1.0",
    "ember-cli-uglify": "^2.0.0",
    "ember-cli-update": "^0.21.4",
    "ember-data": "~3.1.0",
    "ember-export-application-global": "^2.0.0",
    "ember-fetch": "^3.4.5",
    "ember-font-awesome": "^4.0.0-rc.2",
    "ember-load-initializers": "^1.0.0",
    "ember-maybe-import-regenerator": "^0.1.6",
    "ember-moment": "7.5.0",
    "ember-resolver": "^4.0.0",
    "ember-side-menu": "0.0.15",
    "ember-simple-auth": "^1.5.1",
    "ember-source": "~3.1.0",
    "ember-welcome-page": "^3.0.0",
    "eslint-plugin-ember": "^5.0.0",
    "loader.js": "^4.2.3",
    "popper.js": "^1.12.9"
  },
  "engines": {
    "node": "^4.5 || 6.* || >= 7.*"
  },
  "dependencies": {},
  "fastbootDependencies": [
    "fs",
    "path"
  ]
}

Fix breaking changes in FastBoot 1.0

The current ember-cli-fastboot releases (1.0.0-rc.1 and above) introduce breaking changes. These will most likely break your current FastBoot implementation.

See ember-fastboot/ember-cli-fastboot#387 for more information and a guide on how to fix your addon. Also you may want to visit the -fastboot Slack channel to get help from other users.

Note: this issue has been created automatically, by searching for certain patterns in your code. If you think this has been falsely created, feel free to close!

ember-power-calendar squashes moment.tz

Wondering if you know how or why installing ember-power-calendar results in moment.tz === undefined. Searching through the closed issues on here, it seems to be known that other addons might cause this, but I can't figure out why, or how to address the issue.

Thanks!
Adam

Implement Ember.Copyable

Obviously it's easy to copy a moment just by wrapping it in moment(), but if I wanted to copy a moment using Ember.copy(value, true) then moment needs to implement Ember.Copyable for this to work

Is this possible?

A use case could be having an object like the following;

let momentHash = {
  momentA: moment(),
  momentB: moment(),
  momentC: moment.duration(6, 'hours'),
}

Then wanting to do Ember.copy(momentHash,true)

Thoughts?


Issue originally opened here;
adopted-ember-addons/ember-moment#263

Overwriting `moment.now` doesn't seem to work

I am trying to overwrite moment.now function to use a server provided timestamps as per the docs, however, it doesn't seem to work with ember-cli-moment-shim.

Is there anything different I need to do to get this to work with ember-cli-moment-shim?

Issue with new fastboot ember-engines support

when working with the new fastboot support for ember-engines (ember-engines/ember-engines#494) ember-cli-moment-shim is throwing the following error: TypeError: Cannot set property 'compare' of undefined

It looks like this is referring to here: https://github.com/jasonmit/ember-cli-moment-shim/blob/master/addon/index.js

I've been sleuthing through the trees, and I'm not sure I fully get how this library is being handled in Fastboot using the manifest generated files. I see some PRs for engines, and others for fastboot, but anyone familiar with both together?

Tag all releases in git

Recent version tags are missing. Please tag all missing releases. If that's no longer possible, at least tag current versions in 1.x and 2.x` lines.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.