slicejs-cli 2.2.4 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,29 +11,50 @@ import Print from '../Print.js';
|
|
|
11
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Opciones de minificación para diferentes tipos de archivos
|
|
14
|
+
* Opciones de minificación para diferentes tipos de archivos - CORREGIDAS
|
|
15
15
|
*/
|
|
16
16
|
const getMinificationOptions = () => ({
|
|
17
17
|
js: {
|
|
18
18
|
compress: {
|
|
19
19
|
dead_code: true,
|
|
20
|
-
drop_console:
|
|
20
|
+
drop_console: false, // NO remover console.log para evitar problemas
|
|
21
21
|
drop_debugger: true,
|
|
22
|
-
pure_funcs: [
|
|
23
|
-
passes:
|
|
22
|
+
pure_funcs: [], // NO remover funciones específicas
|
|
23
|
+
passes: 1, // Reducir pasadas para ser menos agresivo
|
|
24
|
+
keep_classnames: true, // IMPORTANTE: Preservar nombres de clases
|
|
25
|
+
keep_fnames: true // IMPORTANTE: Preservar nombres de funciones
|
|
24
26
|
},
|
|
25
27
|
mangle: {
|
|
26
|
-
toplevel:
|
|
27
|
-
|
|
28
|
+
toplevel: false, // NO hacer mangle a nivel superior
|
|
29
|
+
keep_classnames: true, // Preservar nombres de clases
|
|
30
|
+
keep_fnames: true, // Preservar nombres de funciones
|
|
31
|
+
reserved: [
|
|
32
|
+
// Framework core
|
|
33
|
+
'Slice', 'Controller', 'StylesManager', 'ThemeManager', 'Logger',
|
|
34
|
+
// Métodos importantes
|
|
35
|
+
'slice', 'build', 'init', 'attachTemplate', 'getComponent',
|
|
36
|
+
// Eventos y propiedades de componentes
|
|
37
|
+
'constructor', 'connectedCallback', 'disconnectedCallback',
|
|
38
|
+
'attributeChangedCallback', 'adoptedCallback',
|
|
39
|
+
// Variables comunes en componentes
|
|
40
|
+
'componentName', 'props', 'options', 'value', 'disabled',
|
|
41
|
+
// HTML Elements y DOM
|
|
42
|
+
'HTMLElement', 'customElements', 'define', 'querySelector',
|
|
43
|
+
'querySelectorAll', 'addEventListener', 'removeEventListener',
|
|
44
|
+
// Métodos de componentes Slice.js
|
|
45
|
+
'setComponentProps', 'componentCategories', 'templates',
|
|
46
|
+
'activeComponents', 'classes', 'requestedStyles'
|
|
47
|
+
]
|
|
28
48
|
},
|
|
29
49
|
output: {
|
|
30
50
|
comments: false,
|
|
31
|
-
beautify: false
|
|
51
|
+
beautify: false,
|
|
52
|
+
keep_quoted_props: true // Preservar propiedades entre comillas
|
|
32
53
|
},
|
|
33
|
-
toplevel:
|
|
54
|
+
toplevel: false // NO optimizar a nivel superior
|
|
34
55
|
},
|
|
35
56
|
css: {
|
|
36
|
-
level:
|
|
57
|
+
level: 1, // Optimización moderada en lugar de agresiva
|
|
37
58
|
returnPromise: false
|
|
38
59
|
},
|
|
39
60
|
html: {
|
|
@@ -41,20 +62,38 @@ const getMinificationOptions = () => ({
|
|
|
41
62
|
removeComments: true,
|
|
42
63
|
removeRedundantAttributes: true,
|
|
43
64
|
removeEmptyAttributes: true,
|
|
44
|
-
minifyCSS:
|
|
45
|
-
minifyJS:
|
|
65
|
+
minifyCSS: false, // NO minificar CSS inline para evitar problemas
|
|
66
|
+
minifyJS: false, // NO minificar JS inline para evitar problemas
|
|
46
67
|
useShortDoctype: true,
|
|
47
|
-
removeAttributeQuotes:
|
|
48
|
-
removeOptionalTags:
|
|
68
|
+
removeAttributeQuotes: false, // Mantener comillas en atributos
|
|
69
|
+
removeOptionalTags: false // Mantener tags opcionales
|
|
49
70
|
}
|
|
50
71
|
});
|
|
51
72
|
|
|
52
73
|
/**
|
|
53
|
-
* Minifica un archivo JavaScript
|
|
74
|
+
* Minifica un archivo JavaScript de forma segura
|
|
54
75
|
*/
|
|
55
76
|
async function minifyJavaScript(content, filename) {
|
|
56
77
|
try {
|
|
57
|
-
|
|
78
|
+
// Para archivos de componentes, ser menos agresivo
|
|
79
|
+
const isComponentFile = filename.includes('/Components/') || filename.includes('\\Components\\');
|
|
80
|
+
|
|
81
|
+
let options = getMinificationOptions().js;
|
|
82
|
+
|
|
83
|
+
if (isComponentFile) {
|
|
84
|
+
// Configuración especial para archivos de componentes
|
|
85
|
+
options = {
|
|
86
|
+
...options,
|
|
87
|
+
compress: {
|
|
88
|
+
...options.compress,
|
|
89
|
+
passes: 1,
|
|
90
|
+
keep_classnames: true,
|
|
91
|
+
keep_fnames: true
|
|
92
|
+
},
|
|
93
|
+
mangle: false // NO hacer mangle en archivos de componentes
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
58
97
|
const result = await terserMinify(content, options);
|
|
59
98
|
|
|
60
99
|
if (result.error) {
|
|
@@ -70,7 +109,9 @@ async function minifyJavaScript(content, filename) {
|
|
|
70
109
|
return result.code;
|
|
71
110
|
} catch (error) {
|
|
72
111
|
Print.error(`Error minifying ${filename}: ${error.message}`);
|
|
73
|
-
|
|
112
|
+
// En caso de error, devolver contenido original
|
|
113
|
+
Print.warning(`Using original content for ${filename}`);
|
|
114
|
+
return content;
|
|
74
115
|
}
|
|
75
116
|
}
|
|
76
117
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// commands/startServer/startServer.js
|
|
1
|
+
// commands/startServer/startServer.js - VERSIÓN SIMPLIFICADA
|
|
2
2
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
@@ -27,7 +27,7 @@ async function checkDevelopmentStructure() {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Inicia el servidor Node.js
|
|
30
|
+
* Inicia el servidor Node.js - SIMPLIFICADO
|
|
31
31
|
*/
|
|
32
32
|
function startNodeServer(port, mode) {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
@@ -50,30 +50,26 @@ function startNodeServer(port, mode) {
|
|
|
50
50
|
reject(error);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
// Manejar Ctrl+C
|
|
53
|
+
// Manejar Ctrl+C - SIMPLIFICADO
|
|
54
54
|
process.on('SIGINT', () => {
|
|
55
55
|
Print.info('Shutting down server...');
|
|
56
56
|
serverProcess.kill('SIGINT');
|
|
57
57
|
process.exit(0);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
// Manejar cierre del proceso
|
|
61
60
|
process.on('SIGTERM', () => {
|
|
62
61
|
serverProcess.kill('SIGTERM');
|
|
63
62
|
});
|
|
64
63
|
|
|
65
|
-
//
|
|
64
|
+
// NO mostrar mensajes duplicados - el api/index.js ya se encarga
|
|
66
65
|
setTimeout(() => {
|
|
67
|
-
Print.success(`${mode === 'production' ? 'Production' : 'Development'} server running at http://localhost:${port}`);
|
|
68
|
-
Print.info(`Serving files from /${mode === 'production' ? 'dist' : 'src'} directory`);
|
|
69
|
-
Print.info('Press Ctrl+C to stop the server');
|
|
70
66
|
resolve(serverProcess);
|
|
71
|
-
},
|
|
67
|
+
}, 500);
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
70
|
|
|
75
71
|
/**
|
|
76
|
-
* Función principal para iniciar servidor - SIMPLIFICADA
|
|
72
|
+
* Función principal para iniciar servidor - ULTRA SIMPLIFICADA
|
|
77
73
|
*/
|
|
78
74
|
export default async function startServer(options = {}) {
|
|
79
75
|
const { mode = 'development', port = 3000 } = options;
|
|
@@ -97,7 +93,7 @@ export default async function startServer(options = {}) {
|
|
|
97
93
|
Print.info('Development mode: serving files from /src with hot reload');
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
// Iniciar el servidor - api/index.js
|
|
96
|
+
// Iniciar el servidor - api/index.js maneja todo automáticamente
|
|
101
97
|
await startNodeServer(port, mode);
|
|
102
98
|
|
|
103
99
|
} catch (error) {
|