Skip to content

Commit d885d91

Browse files
authoredAug 16, 2018
Add es6 loader to webpack (codecombat#4828)
* add es6 loader * CLAs component to es6 * Sort /admin/clas by descending date
1 parent 21a64fb commit d885d91

File tree

5 files changed

+36
-18
lines changed

5 files changed

+36
-18
lines changed
 

‎.babelrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"env"
4+
],
5+
"plugins": [
6+
"syntax-dynamic-import"
7+
]
8+
}

‎app/assets/javascripts/run-tests.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Helper for running tests through Karma.
22
// Hooks into the test view logic for running tests.
3-
require('app/app.js')
3+
require('app/app.js');
44

55
window.userObject = {_id:'1'};
66
window.serverConfig = {picoCTF: false, production: false, buildInfo: { sha: 'dev' }};
77
window.StripeCheckout = {configure: function (){}};
88
window.features = { freeOnly: false, chinaInfra: DEF_CHINA_INFRA }
99
window.serverSession = {};
10-
initialize = require('core/initialize');
10+
const initialize = require('core/initialize');
1111
initialize.init();
1212
application.testing = true;
1313
application.karmaTest = true;
1414
console.debug = function() {}; // Karma conf doesn't seem to work? Debug messages are still emitted when they shouldn't be.
15-
TestView = require('views/TestView');
15+
const TestView = require('views/TestView');
1616
TestView.runTests();

‎app/views/admin/CLAsComponent.vue

+14-15
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@ div#admin-clas-view.container
1616
td {{dateFormat(cla.created)}}
1717
</template>
1818

19-
<script lang="coffee">
20-
co = require('co')
21-
api = require 'core/api'
19+
<script>
20+
import api from 'core/api';
2221
23-
module.exports = Vue.extend({
24-
data: ->
22+
export default Vue.extend({
23+
data: () => ({
2524
clas: []
26-
27-
methods:
28-
dateFormat: (s) -> moment(s).format('llll')
29-
30-
created: co.wrap ->
31-
clas = yield api.clas.getAll()
32-
clas = _.sortBy(clas, (cla) -> (cla.githubUsername || 'zzzzzz').toLowerCase())
33-
clas = _.uniq(clas, true, 'githubUsername')
34-
@clas = clas
35-
})
25+
}),
26+
methods: {
27+
dateFormat: s => moment(s).format('llll')
28+
},
29+
created() {
30+
api.clas.getAll()
31+
.then(clas => _.uniq(_.sortBy(clas, (cla) => new Date(cla.created)).reverse(), true, 'githubUsername'))
32+
.then(clas => this.clas = clas)
33+
}
34+
});
3635
3736
</script>
3837

‎package.json

+5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@
147147
"yamljs": "^0.2.8"
148148
},
149149
"devDependencies": {
150+
"babel-cli": "^6.26.0",
151+
"babel-core": "^6.26.3",
152+
"babel-loader": "^7.1.5",
153+
"babel-plugin-syntax-dynamic-import": "^6.18.0",
154+
"babel-preset-env": "^1.7.0",
150155
"bower": "~1.6.4",
151156
"bundle-loader": "^0.5.5",
152157
"commonjs-require-definition": "0.2.0",

‎webpack.base.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ module.exports = (env) => {
5151
rules: [
5252
{ test: /\.vue$/, use: [{ loader: 'vue-loader' }] },
5353
{ test: /vendor\/scripts\/async.js/, use: [ { loader: 'imports-loader?root=>window' } ] },
54+
{ test: /\.js$/,
55+
exclude: /(node_modules|bower_components|vendor)/,
56+
use: [{
57+
loader: 'babel-loader',
58+
}]
59+
},
5460
{ test: /\.coffee$/, use: [
5561
{ loader: 'coffee-loader' },
5662
] },

0 commit comments

Comments
 (0)
Please sign in to comment.