Skip to content

Commit

Permalink
Migrate moment from bower to npm (#676)
Browse files Browse the repository at this point in the history
* Migrate moment and friends from bower to npm

Using ember-auto-import to ensure that npm packages can seamlessly be
imported

* Don't need include polyfill and it's support is dropped in later
versions

* Update usages of moment to import as expected
  • Loading branch information
Tonkpils authored Oct 6, 2023
1 parent 55d16cd commit 4433fbf
Show file tree
Hide file tree
Showing 35 changed files with 5,600 additions and 515 deletions.
3 changes: 2 additions & 1 deletion frontend/app/components/add-reminder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';
import { translationMacro as t } from "ember-i18n";
import moment from 'moment-timezone';

const {
get,
Expand Down Expand Up @@ -28,7 +29,7 @@ export default Component.extend({
title: null,

timezones: computed(function() {
let originNames = typeof moment !== 'undefined' && moment.tz && moment.tz.names();
let originNames = moment.tz.names();

if(originNames) {
return originNames.map((timezone) => {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/birth-date.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '@ember/component';
import { get, computed } from '@ember/object';
import moment from 'moment';

export default Component.extend({
classNames: ['birthDate'],
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart-navigation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

const {
$,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart-patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Ember from 'ember';
import CheckinByDate from 'flaredown/mixins/checkin-by-date';
import DatesRetriever from 'flaredown/mixins/chart/dates-retriever';
import DS from 'ember-data';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart/g-flat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';
import Graphable from 'flaredown/components/chart/graphable';

const {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart/g-hbi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';
import Colorable from 'flaredown/mixins/colorable';
import Graphable from 'flaredown/components/chart/graphable';

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart/g-timeline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

export default Ember.Component.extend( {
tagName: 'g',
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart/g-trackable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';
import Graphable from 'flaredown/components/chart/graphable';

const {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/chart/g-weather.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';
import Colorable from 'flaredown/mixins/colorable';
import Graphable from 'flaredown/components/chart/graphable';

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/checkin/days-nav.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';
import CheckinByDate from 'flaredown/mixins/checkin-by-date';

const {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/checkin/trackables-step.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';
import DS from 'ember-data';
import moment from 'moment';
import TrackablesFromType from 'flaredown/mixins/trackables-from-type';

const {
Expand Down
4 changes: 4 additions & 0 deletions frontend/app/components/health-chart.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Ember from 'ember';
import Moment from 'moment';
import { extendMoment } from 'moment-range';
import Resizable from './chart/resizable';
import FieldsByUnits from 'flaredown/mixins/fields-by-units';
import DatesRetriever from 'flaredown/mixins/chart/dates-retriever';

const moment = extendMoment(Moment);

const {
get,
set,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/journal-entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/journal-list.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/onboarding/completed-step.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';
import CheckinByDate from 'flaredown/mixins/checkin-by-date';
import moment from 'moment';

export default Ember.Component.extend(CheckinByDate, {

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/pattern/chart-group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

/* global d3 */

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/pattern/chart-hover.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

/* global d3 */

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/pattern/chart-item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

/* global d3 */

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/pattern/index-step.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';
import DS from 'ember-data';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/pattern/svg-initial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';
import DatesRetriever from 'flaredown/mixins/chart/dates-retriever';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/signup-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

const {
get,
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/helpers/checkToday.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { helper } from "@ember/component/helper";
import { helper } from '@ember/component/helper';
import moment from 'moment';

export function checkToday(params) {
let [date, displayText] = params;
Expand Down
1 change: 0 additions & 1 deletion frontend/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<script src="{{rootURL}}assets/drag-drop-polyfill/release/drag-drop-polyfill.js"></script>
<script src="{{rootURL}}assets/vendor.js"></script>

<script src="{{rootURL}}assets/moment-timezone/builds/moment-timezone-with-data.js"></script>
<script src="{{rootURL}}assets/flaredown.js"></script>

{{content-for "body-footer"}}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/mixins/chart/chart-data-retrieve.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/mixins/chart/dates-retriever.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/mixins/checkin-by-date.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';

/*
Assumes the following exist:
Expand Down
1 change: 1 addition & 0 deletions frontend/app/models/checkin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DS from 'ember-data';
import Ember from 'ember';
import moment from 'moment';

const {
attr,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/routes/checkin/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'flaredown/mixins/authenticated-route-mixin';
import CheckinByDate from 'flaredown/mixins/checkin-by-date';
import moment from 'moment';

const {
set,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/routes/checkin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'flaredown/mixins/authenticated-route-mixin';
import CheckinByDate from 'flaredown/mixins/checkin-by-date';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'flaredown/mixins/authenticated-route-mixin';
import CheckinByDate from 'flaredown/mixins/checkin-by-date';
import moment from 'moment';

const {
get,
Expand Down
1 change: 1 addition & 0 deletions frontend/app/transforms/birthdate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DS from 'ember-data';
import Ember from 'ember';
import moment from 'moment';

const { get } = Ember;

Expand Down
5 changes: 0 additions & 5 deletions frontend/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"pace": "vectart/pace",
"pusher": "~3.0.0",
"d3": "~3.5.13",
"momentjs": "~2.11",
"moment-range": "~2.1.0",
"drag-drop-polyfill": "2.0.0-beta.1",
"pickadate": "^3.5.6",
"At.js": "^1.5.4"
},
"devDependencies": {
"moment-timezone": "^0.5.13"
}
}
14 changes: 9 additions & 5 deletions frontend/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
var app = new EmberApp(defaults, {
babel: {
sourceMaps: 'inline'
},

'ember-cli-babel': {},

dotEnv: {
path: {
development: '../backend/.env',
Expand Down Expand Up @@ -48,7 +54,9 @@ module.exports = function(defaults) {

let vendorLib = new Funnel(assetPath, {
files: [
'/pace/pace.js', '/pusher/dist/pusher.js', '/drag-drop-polyfill/release/drag-drop-polyfill.js', '/moment-timezone/builds/moment-timezone-with-data.js'
'/pace/pace.js',
'/pusher/dist/pusher.js',
'/drag-drop-polyfill/release/drag-drop-polyfill.js',
],
destDir: '/assets',
});
Expand All @@ -61,10 +69,6 @@ module.exports = function(defaults) {
// d3
app.import(app.bowerDirectory + '/d3/d3.min.js');

// MomentJS
app.import(app.bowerDirectory + '/momentjs/moment.js');
app.import(app.bowerDirectory + '/moment-range/dist/moment-range.js');

// HTML5 Drag and Drop Polyfill for Mobile
app.import(app.bowerDirectory + '/drag-drop-polyfill/release/drag-drop-polyfill-scroll-behaviour.js');
app.import(app.bowerDirectory + '/drag-drop-polyfill/release/drag-drop-polyfill.css');
Expand Down
Loading

0 comments on commit 4433fbf

Please sign in to comment.