versacompiler 2.1.0 → 2.3.0

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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/compiler/compile.js +2520 -25
  3. package/dist/compiler/error-reporter.js +467 -38
  4. package/dist/compiler/linter.js +72 -1
  5. package/dist/compiler/minify.js +272 -1
  6. package/dist/compiler/minifyTemplate.js +230 -1
  7. package/dist/compiler/module-resolution-optimizer.js +888 -1
  8. package/dist/compiler/parser.js +336 -1
  9. package/dist/compiler/performance-monitor.js +204 -56
  10. package/dist/compiler/tailwindcss.js +39 -1
  11. package/dist/compiler/transform-optimizer.js +392 -1
  12. package/dist/compiler/transformTStoJS.js +16 -1
  13. package/dist/compiler/transforms.js +554 -1
  14. package/dist/compiler/typescript-compiler.js +172 -2
  15. package/dist/compiler/typescript-error-parser.js +281 -10
  16. package/dist/compiler/typescript-manager.js +304 -2
  17. package/dist/compiler/typescript-sync-validator.js +295 -31
  18. package/dist/compiler/typescript-worker-pool.js +936 -1
  19. package/dist/compiler/typescript-worker-thread.cjs +466 -22
  20. package/dist/compiler/typescript-worker.js +339 -1
  21. package/dist/compiler/vuejs.js +396 -37
  22. package/dist/hrm/VueHRM.js +359 -1
  23. package/dist/hrm/errorScreen.js +83 -1
  24. package/dist/hrm/getInstanciaVue.js +313 -1
  25. package/dist/hrm/initHRM.js +586 -1
  26. package/dist/main.js +353 -7
  27. package/dist/servicios/browserSync.js +589 -2
  28. package/dist/servicios/file-watcher.js +425 -4
  29. package/dist/servicios/logger.js +63 -3
  30. package/dist/servicios/readConfig.js +399 -53
  31. package/dist/utils/excluded-modules.js +37 -1
  32. package/dist/utils/module-resolver.js +552 -1
  33. package/dist/utils/promptUser.js +48 -2
  34. package/dist/utils/proxyValidator.js +68 -1
  35. package/dist/utils/resolve-bin.js +58 -1
  36. package/dist/utils/utils.js +21 -1
  37. package/dist/utils/vue-types-setup.js +435 -241
  38. package/dist/wrappers/eslint-node.js +1 -1
  39. package/dist/wrappers/oxlint-node.js +122 -1
  40. package/dist/wrappers/tailwind-node.js +94 -1
  41. package/package.json +109 -104
package/dist/main.js CHANGED
@@ -1,8 +1,354 @@
1
1
  #!/usr/bin/env node
2
- import e from"node:path";import t,{env as n}from"node:process";import{fileURLToPath as r}from"node:url";import{logger as i}from"./servicios/logger.js";import{readConfig as a}from"./servicios/readConfig.js";let o,s,c;n.PATH_PROY=e.dirname(r(import.meta.url)),n.PATH_CONFIG_FILE=e.resolve(t.cwd(),`versacompile.config.ts`);async function l(){return o||(o=(await import(`chalk`)).default),o}async function u(){try{let t=await import(`node:fs/promises`),i=e.resolve(n.PATH_PROY||e.dirname(r(import.meta.url)),`..`,`package.json`),a=await t.readFile(i,`utf-8`);return JSON.parse(a).version||`unknown`}catch{return`unknown`}}async function d(){if(!s){let e=await import(`yargs`),t=await import(`yargs/helpers`);s=e.default,c=t.hideBin}return{yargs:s,hideBin:c}}async function f(){return await import(`./compiler/compile.js`)}async function p(){return await import(`./servicios/browserSync.js`)}async function m(){return await import(`./servicios/file-watcher.js`)}async function h(){return await import(`./servicios/readConfig.js`)}function g(){i.info(`VersaCompiler cerrado correctamente`)}async function _(){let{yargs:r,hideBin:o}=await d(),s=await l(),c=r(o(t.argv)).scriptName(`versa`).usage(s.blue(`VersaCompiler`)+` - Compilador de archivos Vue/TS/JS`).option(`init`,{type:`boolean`,description:`Inicializar la configuración`}).option(`watch`,{type:`boolean`,description:`Habilitar el modo de observación (watch)`,default:!1}).alias(`w`,`watch`).option(`all`,{type:`boolean`,description:`Compilar todos los archivos`}).option(`file`,{type:`string`,description:`Compilar un archivo específico`,alias:`f`}).option(`prod`,{type:`boolean`,description:`Modo producción`}).alias(`p`,`prod`).option(`verbose`,{type:`boolean`,description:`Habilitar salida detallada (verbose)`,default:!1}).alias(`v`,`verbose`).option(`cleanOutput`,{type:`boolean`,description:`Limpiar el directorio de salida antes de compilar`,default:!1}).alias(`co`,`cleanOutput`).option(`cleanCache`,{type:`boolean`,description:`Limpiar el cache de compilación antes de compilar`,default:!1}).alias(`cc`,`cleanCache`).option(`yes`,{type:`boolean`,description:`Confirmar automáticamente las acciones que requieren confirmación`,default:!1}).alias(`y`,`yes`).option(`typeCheck`,{type:`boolean`,description:`Habilitar/Deshabilitar la verificación de tipos. Por defecto --typeCheck=false`,default:!1}).alias(`t`,`typeCheck`);n.tailwindcss!==`false`&&(c=c.option(`tailwind`,{type:`boolean`,description:`Habilitar/Deshabilitar compilación de Tailwind CSS. Por defecto --tailwind=false`,default:!1})),n.linter!==`false`&&(c=c.option(`linter`,{type:`boolean`,description:`Habilitar/Deshabilitar el linter. Por defecto --linter=false`,default:!1}));let _=await c.help().alias(`h`,`help`).command(`* [files...]`,`Compilar archivos específicos`,e=>e.positional(`files`,{describe:`Archivos para compilar`,type:`string`,array:!0})).parse();try{let r=await u(),o=`━`.repeat(60);if(i.log(`
3
- `+s.cyan(o)+`
4
- `+s.bold.cyan(` ⚡ VersaCompiler `)+s.gray(`v${r}`)+`
5
- `+s.gray(` Vue · TypeScript · JavaScript Compiler`)+`
6
- `+s.cyan(o)+`
7
- `),_.init){i.info(`Iniciando la configuración...`);let{initConfig:e}=await h();await e(),t.exit(0)}await a()||t.exit(1),n.isPROD=_.prod?`true`:`false`,n.isALL=_.all?`true`:`false`,n.TAILWIND=_.tailwind===void 0?`true`:String(_.tailwind),n.ENABLE_LINTER=String(_.linter),n.VERBOSE=_.verbose?`true`:`false`,i.info(s.bold.blue(`⚙️ Configuración`)),i.info(s.gray(` ┌─ Modo de ejecución`));let c=[{label:`Observar`,value:_.watch,icon:`👀`},{label:`Todos los archivos`,value:n.isALL===`true`,icon:`📁`},{label:`Archivo único`,value:!!_.file,icon:`📄`},{label:`Producción`,value:n.isPROD===`true`,icon:`🏭`}],l=[{label:`Tailwind`,value:n.TAILWIND===`true`,icon:`🎨`},{label:`Minificación`,value:n.isPROD===`true`,icon:`🗜️`},{label:`Linter`,value:n.ENABLE_LINTER===`true`,icon:`🔍`},{label:`Verificar tipos`,value:_.typeCheck,icon:`📘`},{label:`Detallado`,value:n.VERBOSE===`true`,icon:`📝`}];if(c.forEach(e=>{let t=e.value?s.green(`●`):s.gray(`○`),n=e.value?s.green(e.label):s.gray(e.label);i.info(s.gray(` │ `)+t+` ${e.icon} ${n}`)}),i.info(s.gray(` ├─ Características`)),l.forEach(e=>{let t=e.value?s.green(`●`):s.gray(`○`),n=e.value?s.green(e.label):s.gray(e.label);i.info(s.gray(` │ `)+t+` ${e.icon} ${n}`)}),_.file&&(i.info(s.gray(` ├─ Objetivo`)),i.info(s.gray(` │ `)+s.blue(`📄 `)+_.file)),_.cleanOutput&&(i.info(s.gray(` ├─ Limpieza`)),i.info(s.gray(` │ `)+s.yellow(`🧹 Limpiar salida`))),_.cleanCache&&i.info(s.gray(` │ `)+s.yellow(`🗑️ Limpiar caché`)),i.info(s.gray(` └─ ¡Listo para compilar!`)),i.log(``),n.typeCheck=_.typeCheck?`true`:`false`,n.cleanCache=_.cleanCache?`true`:`false`,n.yes=_.y?`true`:`false`,_.cleanOutput){let{cleanOutputDir:e}=await m();await e(n.PATH_DIST||`./dist`)}if(_.files&&_.files.length>0){i.info(s.yellow(`📄 Compilando ${_.files.length} archivo(s)...`));let e=await import(`node:fs/promises`),{compileFile:n}=await f(),r=!1;for(let t of _.files)try{await e.access(t),i.info(s.blue(`🔄 Compilando: ${t}`));let a=await n(t);a.success?i.info(s.green(`✅ ${t} → ${a.output}`)):(i.error(s.red(`❌ Error al compilar: ${t}`)),r=!0)}catch{i.error(s.red(`❌ El archivo '${t}' no existe.`)),r=!0}t.exit(r?1:0)}if(_.file){i.info(s.yellow(`📄 Compilando archivo: ${_.file}`));let n=await import(`node:fs/promises`),{compileFile:r}=await f(),a;try{await n.access(_.file),a=e.resolve(_.file)}catch{i.error(s.red(`❌ Error: El archivo '${_.file}' no existe.`)),t.exit(1)}let o=await r(a);o.success?(i.info(s.green(`✅ Archivo compilado exitosamente: ${o.output}`)),t.exit(0)):(i.error(s.red(`❌ Error al compilar el archivo: ${_.file}`)),t.exit(1))}if(_.all){let{initCompileAll:e}=await f();await e(),t.exit(0)}if(!_.watch&&n.ENABLE_LINTER===`true`){let{runLinter:e}=await f();await e(!0),t.exit(1)}if(n.TAILWIND===`true`){let e=await(await import(`./compiler/tailwindcss.js`)).generateTailwindCSS();if(typeof e!=`boolean`)if(e?.success)i.info(`\nTailwind CSS compilado🎨 ${e.message}\n`);else{let t=`${e.message}${e.details?`
8
- `+e.details:``}`;i.error(`\n❌ Error al generar Tailwind CSS: ${t}\n`)}}let d,v;if(_.watch){let{browserSyncServer:e}=await p(),{initChokidar:n}=await m();d=await e(),d||t.exit(1),v=await n(d),v||t.exit(1)}t.once(`SIGINT`,async()=>{if(d&&d.exit(),v){let{cleanupWatcher:e}=await m();await e(v)}g(),t.exit(0)}),t.once(`SIGTERM`,async()=>{if(d&&d.exit(),v){let{cleanupWatcher:e}=await m();await e(v)}g(),t.exit(0)})}catch(e){i.error(`Error en la aplicación:`,e),g(),t.exit(1)}}_();
2
+ import * as path from 'node:path';
3
+ import * as processModule from 'node:process';
4
+ const { env } = processModule;
5
+ // Usar el objeto process global para event listeners
6
+ const globalProcess = globalThis.process || processModule;
7
+ // Lazy loading optimizations - Only import lightweight modules synchronously
8
+ import { fileURLToPath } from 'node:url';
9
+ import { logger } from './servicios/logger.js';
10
+ import { readConfig } from './servicios/readConfig.js';
11
+ // Heavy dependencies will be loaded dynamically when needed
12
+ let chalk;
13
+ let yargs;
14
+ let hideBin;
15
+ // Obtener el directorio del archivo actual (src/)
16
+ env.PATH_PROY = path.dirname(fileURLToPath(import.meta.url));
17
+ env.PATH_CONFIG_FILE = path.resolve(globalProcess.cwd(), 'versacompile.config.ts');
18
+ // Lazy loading helper functions
19
+ async function loadChalk() {
20
+ if (!chalk) {
21
+ chalk = (await import('chalk')).default;
22
+ }
23
+ return chalk;
24
+ }
25
+ // Función para obtener la versión del package.json
26
+ async function getPackageVersion() {
27
+ try {
28
+ const fs = await import('node:fs/promises');
29
+ const packageJsonPath = path.resolve(env.PATH_PROY || path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
30
+ const packageContent = await fs.readFile(packageJsonPath, 'utf-8');
31
+ const packageData = JSON.parse(packageContent);
32
+ return packageData.version || 'unknown';
33
+ }
34
+ catch {
35
+ // Fallback si no se puede leer el package.json
36
+ return 'unknown';
37
+ }
38
+ }
39
+ async function loadYargs() {
40
+ if (!yargs) {
41
+ const yargsModule = await import('yargs');
42
+ const helpersModule = await import('yargs/helpers');
43
+ yargs = yargsModule.default;
44
+ hideBin = helpersModule.hideBin;
45
+ }
46
+ return { yargs, hideBin };
47
+ }
48
+ async function loadCompilerModule() {
49
+ return await import('./compiler/compile.js');
50
+ }
51
+ async function loadBrowserSyncModule() {
52
+ return await import('./servicios/browserSync.js');
53
+ }
54
+ async function loadChokidarModule() {
55
+ return await import('./servicios/file-watcher.js');
56
+ }
57
+ async function loadConfigModule() {
58
+ return await import('./servicios/readConfig.js');
59
+ }
60
+ function stopCompile() {
61
+ logger.info('VersaCompiler cerrado correctamente');
62
+ }
63
+ async function main() {
64
+ // Load yargs dynamically
65
+ const { yargs: yargsInstance, hideBin: hideBinFn } = await loadYargs();
66
+ const chalk = await loadChalk();
67
+ let yargInstance = yargsInstance(hideBinFn(globalProcess.argv))
68
+ .scriptName('versa')
69
+ .usage(chalk.blue('VersaCompiler') + ' - Compilador de archivos Vue/TS/JS')
70
+ .option('init', {
71
+ type: 'boolean',
72
+ description: 'Inicializar la configuración',
73
+ })
74
+ .option('watch', {
75
+ type: 'boolean',
76
+ description: 'Habilitar el modo de observación (watch)',
77
+ default: false, // Por defecto, el modo watch está habilitado
78
+ })
79
+ .alias('w', 'watch')
80
+ .option('all', {
81
+ type: 'boolean',
82
+ description: 'Compilar todos los archivos',
83
+ })
84
+ .option('file', {
85
+ type: 'string',
86
+ description: 'Compilar un archivo específico',
87
+ alias: 'f',
88
+ })
89
+ .option('prod', {
90
+ type: 'boolean',
91
+ description: 'Modo producción',
92
+ })
93
+ .alias('p', 'prod')
94
+ .option('verbose', {
95
+ type: 'boolean',
96
+ description: 'Habilitar salida detallada (verbose)',
97
+ default: false, // Por defecto, verbose está deshabilitado
98
+ })
99
+ .alias('v', 'verbose')
100
+ .option('cleanOutput', {
101
+ type: 'boolean',
102
+ description: 'Limpiar el directorio de salida antes de compilar',
103
+ default: false, // Por defecto, clean está deshabilitado
104
+ })
105
+ .alias('co', 'cleanOutput')
106
+ .option('cleanCache', {
107
+ type: 'boolean',
108
+ description: 'Limpiar el cache de compilación antes de compilar',
109
+ default: false, // Por defecto, clean está deshabilitado
110
+ })
111
+ .alias('cc', 'cleanCache')
112
+ .option('yes', {
113
+ type: 'boolean',
114
+ description: 'Confirmar automáticamente las acciones que requieren confirmación',
115
+ default: false, // Por defecto, no se confirma automáticamente
116
+ })
117
+ .alias('y', 'yes')
118
+ .option('typeCheck', {
119
+ type: 'boolean',
120
+ description: 'Habilitar/Deshabilitar la verificación de tipos. Por defecto --typeCheck=false',
121
+ default: false,
122
+ })
123
+ .alias('t', 'typeCheck');
124
+ // Definir la opción tailwind dinámicamente
125
+ // Asumiendo que env.TAILWIND es una cadena que podría ser 'true', 'false', o undefined
126
+ if (env.tailwindcss !== 'false') {
127
+ yargInstance = yargInstance.option('tailwind', {
128
+ type: 'boolean',
129
+ description: 'Habilitar/Deshabilitar compilación de Tailwind CSS. Por defecto --tailwind=false',
130
+ default: false,
131
+ });
132
+ }
133
+ if (env.linter !== 'false') {
134
+ yargInstance = yargInstance.option('linter', {
135
+ type: 'boolean',
136
+ description: 'Habilitar/Deshabilitar el linter. Por defecto --linter=false',
137
+ default: false,
138
+ });
139
+ }
140
+ const argv = (await yargInstance
141
+ .help()
142
+ .alias('h', 'help')
143
+ .command('* [files...]', 'Compilar archivos específicos', (yargs) => {
144
+ return yargs.positional('files', {
145
+ describe: 'Archivos para compilar',
146
+ type: 'string',
147
+ array: true,
148
+ });
149
+ })
150
+ .parse());
151
+ try {
152
+ // 🎨 Header moderno y elegante
153
+ const version = await getPackageVersion();
154
+ const headerLine = '━'.repeat(60);
155
+ logger.log(`\n` +
156
+ chalk.cyan(headerLine) +
157
+ `\n` +
158
+ chalk.bold.cyan(' ⚡ VersaCompiler ') +
159
+ chalk.gray(`v${version}`) +
160
+ `\n` +
161
+ chalk.gray(' Vue · TypeScript · JavaScript Compiler') +
162
+ `\n` +
163
+ chalk.cyan(headerLine) +
164
+ `\n`);
165
+ if (argv.init) {
166
+ logger.info('Iniciando la configuración...');
167
+ const { initConfig } = await loadConfigModule();
168
+ await initConfig();
169
+ globalProcess.exit(0);
170
+ }
171
+ if (!(await readConfig())) {
172
+ globalProcess.exit(1);
173
+ }
174
+ env.isPROD = argv.prod ? 'true' : 'false';
175
+ env.isALL = argv.all ? 'true' : 'false';
176
+ env.TAILWIND =
177
+ argv.tailwind === undefined ? 'true' : String(argv.tailwind);
178
+ env.ENABLE_LINTER = String(argv.linter);
179
+ env.VERBOSE = argv.verbose ? 'true' : 'false'; // 🎯 Configuración moderna y organizada
180
+ logger.info(chalk.bold.blue('⚙️ Configuración'));
181
+ logger.info(chalk.gray(' ┌─ Modo de ejecución'));
182
+ const modes = [
183
+ { label: 'Observar', value: argv.watch, icon: '👀' },
184
+ {
185
+ label: 'Todos los archivos',
186
+ value: env.isALL === 'true',
187
+ icon: '📁',
188
+ },
189
+ { label: 'Archivo único', value: !!argv.file, icon: '📄' },
190
+ { label: 'Producción', value: env.isPROD === 'true', icon: '🏭' },
191
+ ];
192
+ const features = [
193
+ { label: 'Tailwind', value: env.TAILWIND === 'true', icon: '🎨' },
194
+ { label: 'Minificación', value: env.isPROD === 'true', icon: '🗜️' },
195
+ {
196
+ label: 'Linter',
197
+ value: env.ENABLE_LINTER === 'true',
198
+ icon: '🔍',
199
+ },
200
+ { label: 'Verificar tipos', value: argv.typeCheck, icon: '📘' },
201
+ { label: 'Detallado', value: env.VERBOSE === 'true', icon: '📝' },
202
+ ];
203
+ modes.forEach(mode => {
204
+ const status = mode.value ? chalk.green('●') : chalk.gray('○');
205
+ const label = mode.value
206
+ ? chalk.green(mode.label)
207
+ : chalk.gray(mode.label);
208
+ logger.info(chalk.gray(' │ ') + status + ` ${mode.icon} ${label}`);
209
+ });
210
+ logger.info(chalk.gray(' ├─ Características'));
211
+ features.forEach(feature => {
212
+ const status = feature.value ? chalk.green('●') : chalk.gray('○');
213
+ const label = feature.value
214
+ ? chalk.green(feature.label)
215
+ : chalk.gray(feature.label);
216
+ logger.info(chalk.gray(' │ ') + status + ` ${feature.icon} ${label}`);
217
+ });
218
+ if (argv.file) {
219
+ logger.info(chalk.gray(' ├─ Objetivo'));
220
+ logger.info(chalk.gray(' │ ') + chalk.blue('📄 ') + argv.file);
221
+ }
222
+ if (argv.cleanOutput) {
223
+ logger.info(chalk.gray(' ├─ Limpieza'));
224
+ logger.info(chalk.gray(' │ ') + chalk.yellow('🧹 Limpiar salida'));
225
+ }
226
+ if (argv.cleanCache) {
227
+ logger.info(chalk.gray(' │ ') + chalk.yellow('🗑️ Limpiar caché'));
228
+ }
229
+ logger.info(chalk.gray(' └─ ¡Listo para compilar!'));
230
+ logger.log('');
231
+ env.typeCheck = argv.typeCheck ? 'true' : 'false';
232
+ env.cleanCache = argv.cleanCache ? 'true' : 'false';
233
+ env.yes = argv.y ? 'true' : 'false';
234
+ if (argv.cleanOutput) {
235
+ const { cleanOutputDir } = await loadChokidarModule();
236
+ await cleanOutputDir(env.PATH_DIST || './dist');
237
+ }
238
+ // Manejar archivos pasados como argumentos posicionales
239
+ if (argv.files && argv.files.length > 0) {
240
+ logger.info(chalk.yellow(`📄 Compilando ${argv.files.length} archivo(s)...`));
241
+ const fs = await import('node:fs/promises');
242
+ const { compileFile } = await loadCompilerModule();
243
+ let hasErrors = false;
244
+ for (const file of argv.files) {
245
+ try {
246
+ // Verificar si el archivo existe
247
+ await fs.access(file);
248
+ logger.info(chalk.blue(`🔄 Compilando: ${file}`));
249
+ const result = await compileFile(file);
250
+ if (result.success) {
251
+ logger.info(chalk.green(`✅ ${file} → ${result.output}`));
252
+ }
253
+ else {
254
+ logger.error(chalk.red(`❌ Error al compilar: ${file}`));
255
+ hasErrors = true;
256
+ }
257
+ }
258
+ catch {
259
+ logger.error(chalk.red(`❌ El archivo '${file}' no existe.`));
260
+ hasErrors = true;
261
+ }
262
+ }
263
+ globalProcess.exit(hasErrors ? 1 : 0);
264
+ }
265
+ if (argv.file) {
266
+ // Compilar archivo individual
267
+ logger.info(chalk.yellow(`📄 Compilando archivo: ${argv.file}`)); // Verificar si el archivo existe
268
+ const fs = await import('node:fs/promises');
269
+ const { compileFile } = await loadCompilerModule();
270
+ let absolutePathFile;
271
+ try {
272
+ await fs.access(argv.file);
273
+ absolutePathFile = path.resolve(argv.file);
274
+ }
275
+ catch {
276
+ logger.error(chalk.red(`❌ Error: El archivo '${argv.file}' no existe.`));
277
+ globalProcess.exit(1);
278
+ }
279
+ // Compilar el archivo (absolutePathFile está garantizado aquí)
280
+ const result = await compileFile(absolutePathFile);
281
+ if (result.success) {
282
+ logger.info(chalk.green(`✅ Archivo compilado exitosamente: ${result.output}`));
283
+ globalProcess.exit(0);
284
+ }
285
+ else {
286
+ logger.error(chalk.red(`❌ Error al compilar el archivo: ${argv.file}`));
287
+ globalProcess.exit(1);
288
+ }
289
+ }
290
+ if (argv.all) {
291
+ const { initCompileAll } = await loadCompilerModule();
292
+ await initCompileAll();
293
+ globalProcess.exit(0);
294
+ }
295
+ if (!argv.watch) {
296
+ if (env.ENABLE_LINTER === 'true') {
297
+ const { runLinter } = await loadCompilerModule();
298
+ await runLinter(true);
299
+ globalProcess.exit(1);
300
+ }
301
+ }
302
+ if (env.TAILWIND === 'true') {
303
+ const tailwindModule = await import('./compiler/tailwindcss.js');
304
+ const resultTW = await tailwindModule.generateTailwindCSS();
305
+ if (typeof resultTW !== 'boolean') {
306
+ if (resultTW?.success) {
307
+ logger.info(`\nTailwind CSS compilado🎨 ${resultTW.message}\n`);
308
+ }
309
+ else {
310
+ const errorMsg = `${resultTW.message}${resultTW.details ? '\n' + resultTW.details : ''}`;
311
+ logger.error(`\n❌ Error al generar Tailwind CSS: ${errorMsg}\n`);
312
+ }
313
+ }
314
+ }
315
+ let bs;
316
+ let watch;
317
+ if (argv.watch) {
318
+ const { browserSyncServer } = await loadBrowserSyncModule();
319
+ const { initChokidar } = await loadChokidarModule();
320
+ bs = await browserSyncServer();
321
+ if (!bs) {
322
+ globalProcess.exit(1);
323
+ }
324
+ watch = await initChokidar(bs);
325
+ if (!watch) {
326
+ globalProcess.exit(1);
327
+ }
328
+ }
329
+ // ✨ FIX: Cleanup handler para evitar acumulación de listeners
330
+ const cleanupHandler = async () => {
331
+ if (bs) {
332
+ bs.exit();
333
+ }
334
+ if (watch) {
335
+ // ✨ FIX #3: Usar nuevo método cleanupWatcher
336
+ const { cleanupWatcher } = await loadChokidarModule();
337
+ await cleanupWatcher(watch);
338
+ }
339
+ stopCompile();
340
+ globalProcess.exit(0);
341
+ };
342
+ const sigintHandler = () => cleanupHandler();
343
+ const sigtermHandler = () => cleanupHandler();
344
+ globalProcess.on('SIGINT', sigintHandler);
345
+ globalProcess.on('SIGTERM', sigtermHandler);
346
+ }
347
+ catch (error) {
348
+ logger.error('Error en la aplicación:', error);
349
+ stopCompile();
350
+ globalProcess.exit(1);
351
+ }
352
+ }
353
+ main();
354
+ //# sourceMappingURL=main.js.map