Skip to content

Commit cc7596e

Browse files
authored
Merge pull request #1401 from tidev/trimES6mods
feat: reduce empty lines in controllers
2 parents 6ce13b1 + d4444bc commit cc7596e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ var ERROR = 2;
55
module.exports = {
66
env: {
77
'node': true,
8-
'es2017': true
8+
'es2017': true,
9+
'es2020': true
910
},
1011

1112
extends: 'eslint:recommended',

Alloy/commands/compile/ast/controller.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ var U = require('../../../utils'),
66

77
var isBaseControllerExportExpression = types.buildMatchMemberExpression('exports.baseController');
88

9-
const GENCODE_OPTIONS = {
9+
let GENCODE_OPTIONS = {
1010
retainLines: true
1111
};
1212

13-
exports.processController = function(code, file) {
13+
exports.processController = function(code, file, isProduction = false) {
1414
var baseController = '',
1515
moduleCodes = '',
1616
newCode = '',
1717
exportSpecifiers = [];
1818

19+
if (isProduction) {
20+
GENCODE_OPTIONS.retainLines = false;
21+
}
22+
1923
try {
2024
var ast = babylon.parse(code, { sourceFilename: file, sourceType: 'unambiguous' });
2125

Alloy/commands/compile/compilerUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,9 @@ exports.loadController = function(file) {
952952
U.die('Error reading controller file "' + file + '".', e);
953953
}
954954

955+
var isProduction = compilerConfig.alloyConfig?.deploytype === 'production';
955956
// get the base controller for this controller, also process import/export statements
956-
var controller = astController.processController(contents, file);
957+
var controller = astController.processController(contents, file, isProduction);
957958
code.controller = controller.code;
958959
code.parentControllerName = controller.base;
959960
code.es6mods = controller.es6mods;

0 commit comments

Comments
 (0)