versacompiler 2.0.1 → 2.0.3
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 +1086 -116
- package/dist/compiler/module-resolution-optimizer.js +17 -40
- package/dist/compiler/transform-optimizer.js +111 -6
- package/dist/compiler/transforms.js +3 -31
- package/dist/compiler/typescript-error-parser.js +1 -1
- package/dist/compiler/typescript-sync-validator.js +1 -1
- package/dist/compiler/typescript-worker-pool.js +387 -24
- package/dist/compiler/typescript-worker-thread.cjs +1 -2
- package/dist/hrm/getInstanciaVue.js +1 -1
- package/dist/hrm/initHRM.js +1 -1
- package/dist/main.js +64 -17
- package/dist/servicios/browserSync.js +1 -1
- package/dist/servicios/file-watcher.js +85 -22
- package/dist/servicios/logger.js +36 -7
- package/dist/servicios/readConfig.js +1 -1
- package/dist/utils/excluded-modules.js +36 -0
- package/dist/utils/module-resolver.js +4 -33
- package/package.json +2 -1
package/dist/main.js
CHANGED
|
@@ -132,9 +132,18 @@ async function main() {
|
|
|
132
132
|
})
|
|
133
133
|
.parse());
|
|
134
134
|
try {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
// 🎨 Header moderno y elegante
|
|
136
|
+
const headerLine = '━'.repeat(60);
|
|
137
|
+
logger.log(`\n` +
|
|
138
|
+
chalk.cyan(headerLine) +
|
|
139
|
+
`\n` +
|
|
140
|
+
chalk.bold.cyan(' ⚡ VersaCompiler ') +
|
|
141
|
+
chalk.gray('v2.0.3') +
|
|
142
|
+
`\n` +
|
|
143
|
+
chalk.gray(' Vue · TypeScript · JavaScript Compiler') +
|
|
144
|
+
`\n` +
|
|
145
|
+
chalk.cyan(headerLine) +
|
|
146
|
+
`\n`);
|
|
138
147
|
if (argv.init) {
|
|
139
148
|
logger.info('Iniciando la configuración...');
|
|
140
149
|
const { initConfig } = await loadConfigModule();
|
|
@@ -149,20 +158,58 @@ async function main() {
|
|
|
149
158
|
env.TAILWIND =
|
|
150
159
|
argv.tailwind === undefined ? 'true' : String(argv.tailwind);
|
|
151
160
|
env.ENABLE_LINTER = String(argv.linter);
|
|
152
|
-
env.VERBOSE = argv.verbose ? 'true' : 'false';
|
|
153
|
-
logger.info(chalk.
|
|
154
|
-
logger.info(chalk.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
env.VERBOSE = argv.verbose ? 'true' : 'false'; // 🎯 Configuración moderna y organizada
|
|
162
|
+
logger.info(chalk.bold.blue('⚙️ Configuración'));
|
|
163
|
+
logger.info(chalk.gray(' ┌─ Modo de ejecución'));
|
|
164
|
+
const modes = [
|
|
165
|
+
{ label: 'Observar', value: argv.watch, icon: '👀' },
|
|
166
|
+
{
|
|
167
|
+
label: 'Todos los archivos',
|
|
168
|
+
value: env.isALL === 'true',
|
|
169
|
+
icon: '📁',
|
|
170
|
+
},
|
|
171
|
+
{ label: 'Archivo único', value: !!argv.file, icon: '📄' },
|
|
172
|
+
{ label: 'Producción', value: env.isPROD === 'true', icon: '🏭' },
|
|
173
|
+
];
|
|
174
|
+
const features = [
|
|
175
|
+
{ label: 'Tailwind', value: env.TAILWIND === 'true', icon: '🎨' },
|
|
176
|
+
{ label: 'Minificación', value: env.isPROD === 'true', icon: '🗜️' },
|
|
177
|
+
{
|
|
178
|
+
label: 'Linter',
|
|
179
|
+
value: env.ENABLE_LINTER === 'true',
|
|
180
|
+
icon: '🔍',
|
|
181
|
+
},
|
|
182
|
+
{ label: 'Verificar tipos', value: argv.typeCheck, icon: '📘' },
|
|
183
|
+
{ label: 'Detallado', value: env.VERBOSE === 'true', icon: '📝' },
|
|
184
|
+
];
|
|
185
|
+
modes.forEach(mode => {
|
|
186
|
+
const status = mode.value ? chalk.green('●') : chalk.gray('○');
|
|
187
|
+
const label = mode.value
|
|
188
|
+
? chalk.green(mode.label)
|
|
189
|
+
: chalk.gray(mode.label);
|
|
190
|
+
logger.info(chalk.gray(' │ ') + status + ` ${mode.icon} ${label}`);
|
|
191
|
+
});
|
|
192
|
+
logger.info(chalk.gray(' ├─ Características'));
|
|
193
|
+
features.forEach(feature => {
|
|
194
|
+
const status = feature.value ? chalk.green('●') : chalk.gray('○');
|
|
195
|
+
const label = feature.value
|
|
196
|
+
? chalk.green(feature.label)
|
|
197
|
+
: chalk.gray(feature.label);
|
|
198
|
+
logger.info(chalk.gray(' │ ') + status + ` ${feature.icon} ${label}`);
|
|
199
|
+
});
|
|
200
|
+
if (argv.file) {
|
|
201
|
+
logger.info(chalk.gray(' ├─ Objetivo'));
|
|
202
|
+
logger.info(chalk.gray(' │ ') + chalk.blue('📄 ') + argv.file);
|
|
203
|
+
}
|
|
204
|
+
if (argv.cleanOutput) {
|
|
205
|
+
logger.info(chalk.gray(' ├─ Limpieza'));
|
|
206
|
+
logger.info(chalk.gray(' │ ') + chalk.yellow('🧹 Limpiar salida'));
|
|
207
|
+
}
|
|
208
|
+
if (argv.cleanCache) {
|
|
209
|
+
logger.info(chalk.gray(' │ ') + chalk.yellow('🗑️ Limpiar caché'));
|
|
210
|
+
}
|
|
211
|
+
logger.info(chalk.gray(' └─ ¡Listo para compilar!'));
|
|
212
|
+
logger.log('');
|
|
166
213
|
env.typeCheck = argv.typeCheck ? 'true' : 'false';
|
|
167
214
|
env.cleanCache = argv.cleanCache ? 'true' : 'false';
|
|
168
215
|
env.yes = argv.y ? 'true' : 'false';
|
|
@@ -279,7 +279,7 @@ const loadChalk = async () => {
|
|
|
279
279
|
export async function browserSyncServer() {
|
|
280
280
|
try {
|
|
281
281
|
let bs = null;
|
|
282
|
-
const AssetsOmit = env.AssetsOmit === 'true'
|
|
282
|
+
const AssetsOmit = env.AssetsOmit === 'true';
|
|
283
283
|
let proxy = {
|
|
284
284
|
server: './',
|
|
285
285
|
};
|
|
@@ -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
|
/**
|
|
@@ -175,13 +209,19 @@ export async function cleanOutputDir(outputDir, primerInteraccion = true) {
|
|
|
175
209
|
'? (s / N) : ');
|
|
176
210
|
if (answer.toLowerCase() !== 's') {
|
|
177
211
|
logger.info('🛑 Compilación cancelada por el usuario.');
|
|
178
|
-
process.
|
|
212
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
213
|
+
process.exit(0);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
179
216
|
}
|
|
180
217
|
}
|
|
181
218
|
}
|
|
182
219
|
catch (error) {
|
|
183
220
|
logger.error(`Error en la entrada del usuario: ${error}`);
|
|
184
|
-
process.
|
|
221
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
throw error;
|
|
185
225
|
}
|
|
186
226
|
}
|
|
187
227
|
const chalkInstance = await loadChalk();
|
|
@@ -219,11 +259,28 @@ function getAction(ruta, extendsionWatch) {
|
|
|
219
259
|
.find(item => item.ext === ruta.split('.').pop())?.action;
|
|
220
260
|
return action || 'reloadFull';
|
|
221
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Verifica si un archivo pertenece a las rutas adicionales (no compilables)
|
|
264
|
+
*/
|
|
265
|
+
function isAdditionalWatchFile(filePath, additionalPatterns) {
|
|
266
|
+
if (!additionalPatterns || additionalPatterns.length === 0) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
const normalizedPath = normalizeRuta(filePath);
|
|
270
|
+
return additionalPatterns.some(pattern => {
|
|
271
|
+
// Normalizar el patrón también
|
|
272
|
+
const normalizedPattern = pattern.replace(/\\/g, '/');
|
|
273
|
+
return minimatch(normalizedPath, normalizedPattern);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
222
276
|
export async function initChokidar(bs) {
|
|
223
277
|
try {
|
|
224
278
|
if (!env.PATH_SOURCE) {
|
|
225
279
|
logger.error('Error: La variable de entorno PATH_SOURCE no está definida.');
|
|
226
|
-
process.
|
|
280
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
throw new Error('PATH_SOURCE no está definida');
|
|
227
284
|
}
|
|
228
285
|
const watchJS = `${env.PATH_SOURCE}/**/*.js`;
|
|
229
286
|
const watchVue = `${env.PATH_SOURCE}/**/*.vue`;
|
|
@@ -290,27 +347,33 @@ export async function initChokidar(bs) {
|
|
|
290
347
|
watchDebouncer.setBrowserSyncInstance(bs);
|
|
291
348
|
// ✨ OPTIMIZADO: Evento cuando se añade un archivo - Con debouncing
|
|
292
349
|
watcher.on('add', async (ruta) => {
|
|
350
|
+
const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
|
|
293
351
|
const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
|
|
294
352
|
// Usar sistema de debouncing en lugar de compilación inmediata
|
|
295
|
-
watchDebouncer.addChange(ruta, 'add', action);
|
|
353
|
+
watchDebouncer.addChange(ruta, 'add', action, isAdditional);
|
|
296
354
|
});
|
|
297
355
|
// ✨ OPTIMIZADO: Evento cuando se modifica un archivo - Con debouncing
|
|
298
356
|
watcher.on('change', async (ruta) => {
|
|
357
|
+
const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
|
|
299
358
|
const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
|
|
300
359
|
// Usar sistema de debouncing en lugar de compilación inmediata
|
|
301
|
-
watchDebouncer.addChange(ruta, 'change', action);
|
|
360
|
+
watchDebouncer.addChange(ruta, 'change', action, isAdditional);
|
|
302
361
|
});
|
|
303
362
|
// ✨ OPTIMIZADO: Evento cuando se elimina un archivo - Con debouncing
|
|
304
363
|
watcher.on('unlink', async (ruta) => {
|
|
305
364
|
const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
|
|
365
|
+
const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
|
|
306
366
|
// Usar sistema de debouncing para eliminaciones también
|
|
307
|
-
watchDebouncer.addChange(ruta, 'unlink', action);
|
|
367
|
+
watchDebouncer.addChange(ruta, 'unlink', action, isAdditional);
|
|
308
368
|
});
|
|
309
369
|
return watcher;
|
|
310
370
|
}
|
|
311
371
|
catch (error) {
|
|
312
372
|
logger.error(`🚩 :Error al iniciar watch: ${error instanceof Error ? error.message : String(error)}`);
|
|
313
|
-
process.
|
|
373
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
374
|
+
process.exit(1);
|
|
375
|
+
}
|
|
376
|
+
throw error;
|
|
314
377
|
}
|
|
315
378
|
}
|
|
316
379
|
//# sourceMappingURL=file-watcher.js.map
|
package/dist/servicios/logger.js
CHANGED
|
@@ -1,33 +1,62 @@
|
|
|
1
1
|
import * as process from 'node:process';
|
|
2
|
+
// Función para obtener ProgressManager (lazy import para evitar dependencias circulares)
|
|
3
|
+
let getProgressManager = null;
|
|
4
|
+
export function setProgressManagerGetter(getter) {
|
|
5
|
+
getProgressManager = getter;
|
|
6
|
+
}
|
|
2
7
|
class Logger {
|
|
3
8
|
constructor() {
|
|
4
9
|
// Bind console methods
|
|
5
10
|
process.stdout.write = process.stdout.write.bind(process.stdout);
|
|
6
11
|
process.stderr.write = process.stderr.write.bind(process.stderr);
|
|
7
12
|
}
|
|
13
|
+
writeMessage(message, useStderr = false, immediate = false) {
|
|
14
|
+
if (getProgressManager) {
|
|
15
|
+
const progressManager = getProgressManager();
|
|
16
|
+
if (progressManager && progressManager.isActive()) {
|
|
17
|
+
// Si el progreso está activo, usar el sistema de logs apropiado
|
|
18
|
+
if (immediate) {
|
|
19
|
+
progressManager.addImmediateLog(message);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
progressManager.addLog(message);
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Comportamiento normal si no hay progreso activo
|
|
28
|
+
if (useStderr) {
|
|
29
|
+
process.stderr.write(message + '\n');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
process.stdout.write(message + '\n');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
8
35
|
log(...args) {
|
|
9
|
-
|
|
36
|
+
this.writeMessage(args.map(arg => String(arg)).join(' '));
|
|
10
37
|
}
|
|
11
38
|
info(...args) {
|
|
12
|
-
|
|
39
|
+
// En modo verbose, mostrar logs inmediatamente
|
|
40
|
+
const isVerbose = process.env.VERBOSE === 'true';
|
|
41
|
+
this.writeMessage(args.map(arg => String(arg)).join(' '), false, isVerbose);
|
|
13
42
|
}
|
|
14
43
|
error(...args) {
|
|
15
|
-
|
|
44
|
+
this.writeMessage(args.map(arg => String(arg)).join(' '), true);
|
|
16
45
|
}
|
|
17
46
|
warn(...args) {
|
|
18
|
-
|
|
47
|
+
this.writeMessage(args.map(arg => String(arg)).join(' '), true);
|
|
19
48
|
}
|
|
20
49
|
debug(...args) {
|
|
21
|
-
|
|
50
|
+
this.writeMessage(args.map(arg => String(arg)).join(' '));
|
|
22
51
|
}
|
|
23
52
|
fatal(...args) {
|
|
24
|
-
|
|
53
|
+
this.writeMessage(args.map(arg => String(arg)).join(' '), true);
|
|
25
54
|
}
|
|
26
55
|
table(data, title) {
|
|
27
56
|
const tableString = title
|
|
28
57
|
? console.table(data, title)
|
|
29
58
|
: console.table(data);
|
|
30
|
-
|
|
59
|
+
this.writeMessage(String(tableString));
|
|
31
60
|
}
|
|
32
61
|
}
|
|
33
62
|
export const logger = new Logger();
|
|
@@ -341,7 +341,7 @@ export async function readConfig() {
|
|
|
341
341
|
if (!tsConfig.compilerOptions.sourceRoot) {
|
|
342
342
|
env.tsConfig = safeJsonStringify(tsConfig, '{}');
|
|
343
343
|
}
|
|
344
|
-
logger.info('
|
|
344
|
+
logger.info('✅ Configuration loaded and validated successfully');
|
|
345
345
|
return true;
|
|
346
346
|
}
|
|
347
347
|
catch (error) {
|
|
@@ -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
|
|
@@ -256,7 +228,6 @@ function simpleESMResolver(moduleName) {
|
|
|
256
228
|
try {
|
|
257
229
|
const nodeModulesPath = join(cwd(), 'node_modules', moduleName);
|
|
258
230
|
let packagePath;
|
|
259
|
-
let packageJson;
|
|
260
231
|
try {
|
|
261
232
|
packagePath = join(nodeModulesPath, 'package.json');
|
|
262
233
|
if (!fs.existsSync(packagePath)) {
|
|
@@ -266,7 +237,7 @@ function simpleESMResolver(moduleName) {
|
|
|
266
237
|
catch {
|
|
267
238
|
return null;
|
|
268
239
|
}
|
|
269
|
-
packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
|
240
|
+
const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
|
270
241
|
const moduleDir = dirname(packagePath);
|
|
271
242
|
const isESM = packageJson.type === 'module'; // Determinar el entry point ESM/Browser optimizado
|
|
272
243
|
let entryPoint = null;
|
|
@@ -409,7 +380,7 @@ function getNodeModulesRelativePath(fullPath, _fromFile) {
|
|
|
409
380
|
const idx = fullPath.indexOf('node_modules');
|
|
410
381
|
if (idx !== -1) {
|
|
411
382
|
// Extraer solo la parte desde node_modules en adelante
|
|
412
|
-
|
|
383
|
+
const relativePath = fullPath.substring(idx).replace(/\\/g, '/');
|
|
413
384
|
// Devolver ruta absoluta desde la raíz del proyecto (sin ../)
|
|
414
385
|
// Esto permite que los archivos compilados accedan directamente a node_modules
|
|
415
386
|
return '/' + relativePath;
|
|
@@ -456,7 +427,7 @@ export function getModuleSubPath(moduleName, fromFile) {
|
|
|
456
427
|
if (packageJson.exports &&
|
|
457
428
|
typeof packageJson.exports === 'object') {
|
|
458
429
|
const exportKey = `./${subPath}`;
|
|
459
|
-
|
|
430
|
+
const exportPath = packageJson.exports[exportKey];
|
|
460
431
|
if (exportPath) {
|
|
461
432
|
if (typeof exportPath === 'string') {
|
|
462
433
|
return getNodeModulesRelativePath(join(moduleDir, exportPath), fromFile);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versacompiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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",
|