versacompiler 2.0.1 → 2.0.2
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.
- package/dist/compiler/compile.js +344 -7
- package/dist/compiler/module-resolution-optimizer.js +14 -36
- package/dist/compiler/transform-optimizer.js +111 -6
- package/dist/compiler/transforms.js +3 -31
- package/dist/compiler/typescript-worker-pool.js +387 -21
- package/dist/servicios/file-watcher.js +69 -18
- package/dist/utils/excluded-modules.js +36 -0
- package/dist/utils/module-resolver.js +1 -29
- package/package.json +2 -1
|
@@ -2,6 +2,7 @@ import { readdir, rm, stat, unlink } from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import process, { env } from 'node:process';
|
|
4
4
|
import * as chokidar from 'chokidar';
|
|
5
|
+
import { minimatch } from 'minimatch';
|
|
5
6
|
import { getOutputPath, initCompile, normalizeRuta } from '../compiler/compile.js';
|
|
6
7
|
import { promptUser } from '../utils/promptUser.js';
|
|
7
8
|
import { emitirCambios } from './browserSync.js';
|
|
@@ -30,7 +31,7 @@ class WatchDebouncer {
|
|
|
30
31
|
/**
|
|
31
32
|
* Añade un cambio al sistema de debouncing
|
|
32
33
|
*/
|
|
33
|
-
addChange(filePath, action, extensionAction) {
|
|
34
|
+
addChange(filePath, action, extensionAction, isAdditionalFile = false) {
|
|
34
35
|
// Normalizar ruta para evitar duplicados
|
|
35
36
|
const normalizedPath = normalizeRuta(filePath);
|
|
36
37
|
// Agregar o actualizar el cambio pendiente
|
|
@@ -39,6 +40,7 @@ class WatchDebouncer {
|
|
|
39
40
|
action,
|
|
40
41
|
timestamp: Date.now(),
|
|
41
42
|
extensionAction,
|
|
43
|
+
isAdditionalFile,
|
|
42
44
|
});
|
|
43
45
|
// Reiniciar el timer de debounce
|
|
44
46
|
this.resetDebounceTimer();
|
|
@@ -88,39 +90,71 @@ class WatchDebouncer {
|
|
|
88
90
|
this.resetDebounceTimer();
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
+
} /**
|
|
93
94
|
* Procesa cambios de eliminación
|
|
94
95
|
*/
|
|
95
96
|
async processDeleteChanges(deleteChanges) {
|
|
96
97
|
for (const change of deleteChanges) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
logger.info(`Archivo eliminado: ${change.filePath}`);
|
|
98
|
+
if (change.isAdditionalFile) {
|
|
99
|
+
// ✨ Archivos adicionales: solo reload, sin eliminar del output
|
|
100
|
+
logger.info(`\n🗑️ Archivo adicional eliminado: ${change.filePath}`);
|
|
101
101
|
emitirCambios(this.browserSyncInstance, 'reloadFull', change.filePath);
|
|
102
102
|
}
|
|
103
|
+
else {
|
|
104
|
+
// Archivos compilables: eliminar del output
|
|
105
|
+
logger.info(`\n🗑️ Eliminando archivo compilado: ${change.filePath}`);
|
|
106
|
+
const result = await deleteFile(getOutputPath(change.filePath));
|
|
107
|
+
if (result) {
|
|
108
|
+
logger.info(`Archivo eliminado: ${change.filePath}`);
|
|
109
|
+
emitirCambios(this.browserSyncInstance, 'reloadFull', change.filePath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
114
|
/**
|
|
106
115
|
* Procesa cambios de compilación en paralelo con límite de concurrencia
|
|
107
116
|
*/
|
|
108
117
|
async processCompileChanges(compileChanges) {
|
|
118
|
+
// ✨ NUEVO: Separar archivos adicionales de archivos compilables
|
|
119
|
+
const additionalFiles = compileChanges.filter(c => c.isAdditionalFile);
|
|
120
|
+
const compilableFiles = compileChanges.filter(c => !c.isAdditionalFile);
|
|
121
|
+
// ✨ Procesar archivos adicionales (solo reload, sin compilación)
|
|
122
|
+
if (additionalFiles.length > 0) {
|
|
123
|
+
await this.processAdditionalFiles(additionalFiles);
|
|
124
|
+
}
|
|
125
|
+
// Procesar archivos compilables normalmente
|
|
126
|
+
if (compilableFiles.length > 0) {
|
|
127
|
+
await this.processCompilableFiles(compilableFiles);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* ✨ RENOMBRADO: Procesa archivos compilables
|
|
132
|
+
*/
|
|
133
|
+
async processCompilableFiles(compilableFiles) {
|
|
109
134
|
const chalkInstance = await loadChalk();
|
|
110
135
|
// Procesar en batches para evitar sobrecarga
|
|
111
|
-
for (let i = 0; i <
|
|
112
|
-
const batch =
|
|
113
|
-
// Mostrar información del batch
|
|
136
|
+
for (let i = 0; i < compilableFiles.length; i += this.BATCH_SIZE) {
|
|
137
|
+
const batch = compilableFiles.slice(i, i + this.BATCH_SIZE);
|
|
114
138
|
if (batch.length > 1) {
|
|
115
|
-
logger.info(chalkInstance.cyan(`📦 Procesando batch de ${batch.length} archivos (${i + 1}-${Math.min(i + this.BATCH_SIZE,
|
|
139
|
+
logger.info(chalkInstance.cyan(`📦 Procesando batch de ${batch.length} archivos compilables (${i + 1}-${Math.min(i + this.BATCH_SIZE, compilableFiles.length)} de ${compilableFiles.length})`));
|
|
116
140
|
}
|
|
117
|
-
// Procesar batch en paralelo con límite de concurrencia
|
|
118
141
|
const promises = batch.map(change => this.compileFile(change));
|
|
119
142
|
await Promise.allSettled(promises);
|
|
120
143
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
144
|
+
if (compilableFiles.length > 1) {
|
|
145
|
+
logger.info(chalkInstance.green(`✅ Batch completado: ${compilableFiles.length} archivos compilados`));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* ✨ NUEVO: Procesa archivos adicionales (solo reloadFull)
|
|
150
|
+
*/
|
|
151
|
+
async processAdditionalFiles(additionalFiles) {
|
|
152
|
+
const chalkInstance = await loadChalk();
|
|
153
|
+
logger.info(chalkInstance.blue(`🔄 Recargando ${additionalFiles.length} archivo(s) adicional(es) (sin compilación)`));
|
|
154
|
+
for (const change of additionalFiles) {
|
|
155
|
+
logger.info(`📄 Archivo adicional modificado: ${change.filePath}`);
|
|
156
|
+
// Solo hacer reloadFull, sin compilación
|
|
157
|
+
emitirCambios(this.browserSyncInstance, 'reloadFull', change.filePath);
|
|
124
158
|
}
|
|
125
159
|
}
|
|
126
160
|
/**
|
|
@@ -219,6 +253,20 @@ function getAction(ruta, extendsionWatch) {
|
|
|
219
253
|
.find(item => item.ext === ruta.split('.').pop())?.action;
|
|
220
254
|
return action || 'reloadFull';
|
|
221
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Verifica si un archivo pertenece a las rutas adicionales (no compilables)
|
|
258
|
+
*/
|
|
259
|
+
function isAdditionalWatchFile(filePath, additionalPatterns) {
|
|
260
|
+
if (!additionalPatterns || additionalPatterns.length === 0) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
const normalizedPath = normalizeRuta(filePath);
|
|
264
|
+
return additionalPatterns.some(pattern => {
|
|
265
|
+
// Normalizar el patrón también
|
|
266
|
+
const normalizedPattern = pattern.replace(/\\/g, '/');
|
|
267
|
+
return minimatch(normalizedPath, normalizedPattern);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
222
270
|
export async function initChokidar(bs) {
|
|
223
271
|
try {
|
|
224
272
|
if (!env.PATH_SOURCE) {
|
|
@@ -290,21 +338,24 @@ export async function initChokidar(bs) {
|
|
|
290
338
|
watchDebouncer.setBrowserSyncInstance(bs);
|
|
291
339
|
// ✨ OPTIMIZADO: Evento cuando se añade un archivo - Con debouncing
|
|
292
340
|
watcher.on('add', async (ruta) => {
|
|
341
|
+
const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
|
|
293
342
|
const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
|
|
294
343
|
// Usar sistema de debouncing en lugar de compilación inmediata
|
|
295
|
-
watchDebouncer.addChange(ruta, 'add', action);
|
|
344
|
+
watchDebouncer.addChange(ruta, 'add', action, isAdditional);
|
|
296
345
|
});
|
|
297
346
|
// ✨ OPTIMIZADO: Evento cuando se modifica un archivo - Con debouncing
|
|
298
347
|
watcher.on('change', async (ruta) => {
|
|
348
|
+
const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
|
|
299
349
|
const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
|
|
300
350
|
// Usar sistema de debouncing en lugar de compilación inmediata
|
|
301
|
-
watchDebouncer.addChange(ruta, 'change', action);
|
|
351
|
+
watchDebouncer.addChange(ruta, 'change', action, isAdditional);
|
|
302
352
|
});
|
|
303
353
|
// ✨ OPTIMIZADO: Evento cuando se elimina un archivo - Con debouncing
|
|
304
354
|
watcher.on('unlink', async (ruta) => {
|
|
305
355
|
const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
|
|
356
|
+
const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
|
|
306
357
|
// Usar sistema de debouncing para eliminaciones también
|
|
307
|
-
watchDebouncer.addChange(ruta, 'unlink', action);
|
|
358
|
+
watchDebouncer.addChange(ruta, 'unlink', action, isAdditional);
|
|
308
359
|
});
|
|
309
360
|
return watcher;
|
|
310
361
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lista centralizada de módulos excluidos de la resolución automática
|
|
3
|
+
* Estos módulos se mantienen con su importación original sin transformar
|
|
4
|
+
*/
|
|
5
|
+
export const EXCLUDED_MODULES = new Set([
|
|
6
|
+
// Módulos de Vue.js que requieren resolución específica
|
|
7
|
+
'vue/compiler-sfc',
|
|
8
|
+
'vue/dist/vue.runtime.esm-bundler',
|
|
9
|
+
'@vue/compiler-sfc',
|
|
10
|
+
'@vue/compiler-dom',
|
|
11
|
+
'@vue/runtime-core',
|
|
12
|
+
'@vue/runtime-dom',
|
|
13
|
+
// Módulos de oxc-parser que tienen dependencias específicas de WASM
|
|
14
|
+
'oxc-parser',
|
|
15
|
+
'oxc-parser/wasm',
|
|
16
|
+
'oxc-minify',
|
|
17
|
+
'oxc-minify/browser',
|
|
18
|
+
'@oxc-parser/binding-wasm32-wasi',
|
|
19
|
+
'@oxc-minify/binding-wasm32-wasi',
|
|
20
|
+
// Módulos de TypeScript que pueden tener resoluciones complejas
|
|
21
|
+
'typescript',
|
|
22
|
+
'typescript/lib/typescript',
|
|
23
|
+
// Módulos de herramientas de build y utilidades que deben mantenerse originales
|
|
24
|
+
'yargs',
|
|
25
|
+
'yargs/helpers',
|
|
26
|
+
'yargs-parser',
|
|
27
|
+
'chalk',
|
|
28
|
+
'browser-sync',
|
|
29
|
+
'chokidar',
|
|
30
|
+
'get-port',
|
|
31
|
+
'execa',
|
|
32
|
+
'find-root',
|
|
33
|
+
'fs-extra',
|
|
34
|
+
'minimatch', // ✅ Incluir minimatch aquí
|
|
35
|
+
]);
|
|
36
|
+
//# sourceMappingURL=excluded-modules.js.map
|
|
@@ -5,35 +5,7 @@ import { cwd, env } from 'node:process';
|
|
|
5
5
|
// import pkg from '/node_modules/enhanced-resolve/lib/index.js';
|
|
6
6
|
// import resolve from '/node_modules/resolve/index.js';
|
|
7
7
|
import { logger } from '../servicios/logger.js';
|
|
8
|
-
|
|
9
|
-
// Estos módulos se mantienen con su importación original sin transformar
|
|
10
|
-
const EXCLUDED_MODULES = new Set([
|
|
11
|
-
'vue/compiler-sfc',
|
|
12
|
-
'vue/dist/vue.runtime.esm-bundler',
|
|
13
|
-
'@vue/compiler-sfc',
|
|
14
|
-
'@vue/compiler-dom',
|
|
15
|
-
'@vue/runtime-core',
|
|
16
|
-
'@vue/runtime-dom', // Módulos de oxc-parser que tienen dependencias específicas de WASM
|
|
17
|
-
'oxc-parser',
|
|
18
|
-
'oxc-parser/wasm',
|
|
19
|
-
'oxc-minify',
|
|
20
|
-
'oxc-minify/browser',
|
|
21
|
-
'@oxc-parser/binding-wasm32-wasi',
|
|
22
|
-
'@oxc-minify/binding-wasm32-wasi',
|
|
23
|
-
// Módulos de TypeScript que pueden tener resoluciones complejas
|
|
24
|
-
'typescript',
|
|
25
|
-
// Agregar más módulos problemáticos aquí según sea necesario
|
|
26
|
-
'yargs',
|
|
27
|
-
'yargs/helpers',
|
|
28
|
-
'yargs-parser',
|
|
29
|
-
'chalk',
|
|
30
|
-
'browser-sync',
|
|
31
|
-
'chokidar',
|
|
32
|
-
'get-port',
|
|
33
|
-
'execa',
|
|
34
|
-
'find-root',
|
|
35
|
-
'fs-extra',
|
|
36
|
-
]);
|
|
8
|
+
import { EXCLUDED_MODULES } from './excluded-modules.js';
|
|
37
9
|
// function resolveESMWithLibrary(moduleName: string): string | null {
|
|
38
10
|
// try {
|
|
39
11
|
// // Resolver el módulo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versacompiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Una herramienta para compilar y minificar archivos .vue, .js y .ts para proyectos de Vue 3 con soporte para TypeScript.",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"find-root": "^1.1.0",
|
|
53
53
|
"fs-extra": "^11.3.0",
|
|
54
54
|
"get-port": "^7.1.0",
|
|
55
|
+
"minimatch": "^10.0.1",
|
|
55
56
|
"oxc-minify": "^0.72.3",
|
|
56
57
|
"oxc-parser": "^0.72.3",
|
|
57
58
|
"oxc-transform": "^0.72.3",
|