Skip to content

feat: reduce empty lines in controllers #1401

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 14 commits into from
Apr 28, 2025
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var ERROR = 2;
module.exports = {
env: {
'node': true,
'es2017': true
'es2017': true,
'es2020': true
},

extends: 'eslint:recommended',
Expand Down
8 changes: 6 additions & 2 deletions Alloy/commands/compile/ast/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ var U = require('../../../utils'),

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

const GENCODE_OPTIONS = {
let GENCODE_OPTIONS = {
retainLines: true
};

exports.processController = function(code, file) {
exports.processController = function(code, file, isProduction = false) {
var baseController = '',
moduleCodes = '',
newCode = '',
exportSpecifiers = [];

if (isProduction) {
GENCODE_OPTIONS.retainLines = false;
}

try {
var ast = babylon.parse(code, { sourceFilename: file, sourceType: 'unambiguous' });

Expand Down
3 changes: 2 additions & 1 deletion Alloy/commands/compile/compilerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,9 @@ exports.loadController = function(file) {
U.die('Error reading controller file "' + file + '".', e);
}

var isProduction = compilerConfig.alloyConfig?.deploytype === 'production';
// get the base controller for this controller, also process import/export statements
var controller = astController.processController(contents, file);
var controller = astController.processController(contents, file, isProduction);
code.controller = controller.code;
code.parentControllerName = controller.base;
code.es6mods = controller.es6mods;
Expand Down