Skip to content

feat(app): compile server with babel-runtime #1260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,22 +581,33 @@ module.exports = function (grunt) {
ext: '.js'
}]
}
},<% } if(filters.babel) { %>
},<% } %>

// Compiles ES6 to JavaScript using Babel
babel: {
options: {
sourceMap: true
},
},<% if(filters.babel) { %>
client: {
files: [{
expand: true,
cwd: '<%%= yeoman.client %>',
src: ['{app,components}/**/!(*.spec).js'],
dest: '.tmp'
}]
},<% } %>
server: {
options: {
optional: ['runtime']
},
files: [{
expand: true,
cwd: '<%%= yeoman.server %>',
src: ['**/*.{js,json}'],
dest: '<%%= yeoman.dist %>/<%%= yeoman.server %>'
}]
}
},<% } if(filters.stylus) { %>
},<% if(filters.stylus) { %>

// Compiles Stylus to CSS
stylus: {
Expand Down Expand Up @@ -902,6 +913,7 @@ module.exports = function (grunt) {
'concat',
'ngAnnotate',
'copy:dist',
'babel:server',
'cdnify',
'cssmin',
'uglify',
Expand Down
3 changes: 2 additions & 1 deletion app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"composable-middleware": "^0.3.0",
"lodash": "^3.10.1",
"lusca": "^1.3.0",
"babel-core": "^5.6.4",<% if (filters.jade) { %>
"babel-runtime": "^5.8.20",<% if (filters.jade) { %>
"jade": "^1.11.0",<% } %><% if (filters.html) { %>
"ejs": "^2.3.3",<% } %><% if (filters.mongoose) { %>
"mongoose": "^4.1.2",
Expand All @@ -37,6 +37,7 @@
},
"devDependencies": {
"autoprefixer": "^6.0.0",
"babel-core": "^5.6.4",
"grunt": "~0.4.5",
"grunt-wiredep": "^2.0.0",
"grunt-concurrent": "^2.0.1",
Expand Down
3 changes: 0 additions & 3 deletions app/templates/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

'use strict';

// Set default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

import express from 'express';<% if (filters.mongoose) { %>
import mongoose from 'mongoose';<% } %><% if (filters.sequelize) { %>
import sqldb from './sqldb';<% } %>
Expand Down
9 changes: 7 additions & 2 deletions app/templates/server/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
'use strict';

// Register the Babel require hook
require('babel-core/register');
// Set default node environment to development
var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';

if (env === 'production' || env === 'test') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was missing env === 'test'.

// Register the Babel require hook
require('babel-core/register');
}

// Export the application
exports = module.exports = require('./app');