versacompiler 2.0.7 → 2.0.8

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 (39) hide show
  1. package/dist/compiler/compile.js +26 -2332
  2. package/dist/compiler/error-reporter.js +38 -467
  3. package/dist/compiler/linter.js +1 -72
  4. package/dist/compiler/minify.js +1 -229
  5. package/dist/compiler/module-resolution-optimizer.js +1 -821
  6. package/dist/compiler/parser.js +1 -203
  7. package/dist/compiler/performance-monitor.js +56 -192
  8. package/dist/compiler/tailwindcss.js +1 -39
  9. package/dist/compiler/transform-optimizer.js +1 -392
  10. package/dist/compiler/transformTStoJS.js +1 -16
  11. package/dist/compiler/transforms.js +1 -550
  12. package/dist/compiler/typescript-compiler.js +2 -172
  13. package/dist/compiler/typescript-error-parser.js +10 -281
  14. package/dist/compiler/typescript-manager.js +2 -273
  15. package/dist/compiler/typescript-sync-validator.js +31 -295
  16. package/dist/compiler/typescript-worker-pool.js +1 -842
  17. package/dist/compiler/typescript-worker-thread.cjs +41 -466
  18. package/dist/compiler/typescript-worker.js +1 -339
  19. package/dist/compiler/vuejs.js +37 -392
  20. package/dist/hrm/VueHRM.js +1 -353
  21. package/dist/hrm/errorScreen.js +1 -83
  22. package/dist/hrm/getInstanciaVue.js +1 -313
  23. package/dist/hrm/initHRM.js +1 -141
  24. package/dist/main.js +7 -347
  25. package/dist/servicios/browserSync.js +5 -501
  26. package/dist/servicios/file-watcher.js +4 -379
  27. package/dist/servicios/logger.js +3 -63
  28. package/dist/servicios/readConfig.js +105 -430
  29. package/dist/utils/excluded-modules.js +1 -36
  30. package/dist/utils/module-resolver.js +1 -466
  31. package/dist/utils/promptUser.js +2 -48
  32. package/dist/utils/proxyValidator.js +1 -68
  33. package/dist/utils/resolve-bin.js +1 -48
  34. package/dist/utils/utils.js +1 -21
  35. package/dist/utils/vue-types-setup.js +241 -435
  36. package/dist/wrappers/eslint-node.js +1 -145
  37. package/dist/wrappers/oxlint-node.js +1 -120
  38. package/dist/wrappers/tailwind-node.js +1 -92
  39. package/package.json +36 -35
@@ -1,430 +1,105 @@
1
- import { normalize, relative, resolve } from 'node:path';
2
- import * as process from 'node:process';
3
- import { env } from 'node:process';
4
- import { pathToFileURL } from 'node:url';
5
- import { logger } from './logger.js';
6
- /**
7
- * Utilidades de seguridad para validar configuraciones
8
- */
9
- class SecurityValidators {
10
- static MAX_PATH_LENGTH = 260; // Windows MAX_PATH limit
11
- static MAX_CONFIG_SIZE = 1024 * 1024; // 1MB max config size
12
- static ALLOWED_PATH_CHARS = /^[a-zA-Z0-9.\-_/\\:@ ()[\]]+$/;
13
- static DANGEROUS_PATTERNS = [
14
- /\.\./, // Path traversal
15
- /[;&|`$]/, // Command injection characters
16
- /\$\(/, // Command substitution
17
- /`.*`/, // Backtick execution
18
- /\|\s*[a-zA-Z]/, // Pipe to commands
19
- ];
20
- /**
21
- * Valida que una ruta no contenga path traversal
22
- */
23
- static validatePath(path) {
24
- if (!path || typeof path !== 'string') {
25
- return false;
26
- }
27
- if (path.length > this.MAX_PATH_LENGTH) {
28
- logger.warn(`Ruta demasiado larga: ${path.length} caracteres`);
29
- return false;
30
- }
31
- // Normalizar la ruta para detectar path traversal
32
- const normalizedPath = normalize(path);
33
- const resolvedPath = resolve(process.cwd(), normalizedPath);
34
- const relativePath = relative(process.cwd(), resolvedPath);
35
- // Verificar si la ruta trata de salir del directorio actual
36
- if (relativePath.startsWith('..') || normalizedPath.includes('..')) {
37
- logger.error(`Detectado intento de path traversal: ${path}`);
38
- return false;
39
- }
40
- // Verificar caracteres permitidos
41
- if (!this.ALLOWED_PATH_CHARS.test(path)) {
42
- logger.error(`Caracteres no permitidos en la ruta: ${path}`);
43
- return false;
44
- }
45
- return true;
46
- }
47
- /**
48
- * Valida que un comando no contenga inyección de código
49
- */
50
- static validateCommand(command) {
51
- if (!command || typeof command !== 'string') {
52
- return false;
53
- }
54
- if (command.length > this.MAX_PATH_LENGTH) {
55
- logger.warn(`Comando demasiado largo: ${command.length} caracteres`);
56
- return false;
57
- }
58
- // Verificar patrones peligrosos
59
- for (const pattern of this.DANGEROUS_PATTERNS) {
60
- if (pattern.test(command)) {
61
- logger.error(`Detectado patrón peligroso en comando: ${command}`);
62
- return false;
63
- }
64
- }
65
- // Solo permitir comandos que terminen en extensiones seguras
66
- const allowedExecutables = [
67
- '.exe',
68
- '.cmd',
69
- '.bat',
70
- '.sh',
71
- '.js',
72
- '.ts',
73
- ];
74
- const hasAllowedExtension = allowedExecutables.some(ext => command.toLowerCase().includes(ext) ||
75
- command.startsWith('./node_modules/.bin/') ||
76
- command.startsWith('npx '));
77
- if (!hasAllowedExtension) {
78
- logger.error(`Comando no permitido: ${command}`);
79
- return false;
80
- }
81
- return true;
82
- }
83
- /**
84
- * Valida configuración de bundlers
85
- */
86
- static validateBundlers(bundlers) {
87
- if (!Array.isArray(bundlers)) {
88
- logger.error('bundlers debe ser un array');
89
- return false;
90
- }
91
- for (const entry of bundlers) {
92
- if (!entry || typeof entry !== 'object') {
93
- logger.error('Cada entrada de bundler debe ser un objeto');
94
- return false;
95
- }
96
- if (!entry.name || typeof entry.name !== 'string') {
97
- logger.error('Cada entrada de bundler debe tener un nombre válido');
98
- return false;
99
- }
100
- if (!entry.fileInput || typeof entry.fileInput !== 'string') {
101
- logger.error('Cada entrada de bundler debe tener un fileInput válido');
102
- return false;
103
- }
104
- if (!this.validatePath(entry.fileInput)) {
105
- logger.error(`Ruta de entrada no válida: ${entry.fileInput}`);
106
- return false;
107
- }
108
- if (!entry.fileOutput || typeof entry.fileOutput !== 'string') {
109
- logger.error('Cada entrada de bundler debe tener un fileOutput válido');
110
- return false;
111
- }
112
- if (!this.validatePath(entry.fileOutput)) {
113
- logger.error(`Ruta de salida no válida: ${entry.fileOutput}`);
114
- return false;
115
- }
116
- }
117
- return true;
118
- }
119
- /**
120
- * Valida la estructura de configuración
121
- */
122
- static validateConfigStructure(config) {
123
- if (!config || typeof config !== 'object') {
124
- logger.error('La configuración debe ser un objeto');
125
- return false;
126
- }
127
- if (!config.compilerOptions ||
128
- typeof config.compilerOptions !== 'object') {
129
- logger.error('compilerOptions es requerido y debe ser un objeto');
130
- return false;
131
- }
132
- if (!config.compilerOptions.pathsAlias ||
133
- typeof config.compilerOptions.pathsAlias !== 'object') {
134
- logger.error('pathsAlias es requerido y debe ser un objeto');
135
- return false;
136
- }
137
- // Validar pathsAlias
138
- for (const [key, value] of Object.entries(config.compilerOptions.pathsAlias)) {
139
- if (!Array.isArray(value)) {
140
- logger.error(`pathsAlias["${key}"] debe ser un array`);
141
- return false;
142
- }
143
- for (const path of value) {
144
- if (typeof path !== 'string') {
145
- logger.error(`Todas las rutas en pathsAlias["${key}"] deben ser strings`);
146
- return false;
147
- }
148
- if (!this.validatePath(path.replace('/*', ''))) {
149
- logger.error(`Ruta no válida en pathsAlias["${key}"]: ${path}`);
150
- return false;
151
- }
152
- }
153
- }
154
- // Validar sourceRoot si existe
155
- if (config.compilerOptions.sourceRoot &&
156
- !this.validatePath(config.compilerOptions.sourceRoot)) {
157
- return false;
158
- }
159
- // Validar outDir si existe
160
- if (config.compilerOptions.outDir &&
161
- !this.validatePath(config.compilerOptions.outDir)) {
162
- return false;
163
- }
164
- // Validar linter si existe
165
- if (config.linter && config.linter !== false) {
166
- if (!Array.isArray(config.linter)) {
167
- logger.error('linter debe ser un array o false');
168
- return false;
169
- }
170
- for (const linter of config.linter) {
171
- if (!this.validateLinter(linter)) {
172
- return false;
173
- }
174
- }
175
- }
176
- return true;
177
- }
178
- /**
179
- * Valida configuración de linter
180
- */
181
- static validateLinter(linter) {
182
- if (!linter || typeof linter !== 'object') {
183
- logger.error('Cada linter debe ser un objeto');
184
- return false;
185
- }
186
- if (!linter.name || typeof linter.name !== 'string') {
187
- logger.error('Linter debe tener un nombre válido');
188
- return false;
189
- }
190
- if (!linter.bin || typeof linter.bin !== 'string') {
191
- logger.error('Linter debe tener un bin válido');
192
- return false;
193
- }
194
- if (!this.validateCommand(linter.bin)) {
195
- return false;
196
- }
197
- if (!linter.configFile || typeof linter.configFile !== 'string') {
198
- logger.error('Linter debe tener un configFile válido');
199
- return false;
200
- }
201
- if (!this.validatePath(linter.configFile)) {
202
- return false;
203
- }
204
- if (linter.paths && !Array.isArray(linter.paths)) {
205
- logger.error('linter.paths debe ser un array');
206
- return false;
207
- }
208
- if (linter.paths) {
209
- for (const path of linter.paths) {
210
- if (typeof path !== 'string' || !this.validatePath(path)) {
211
- logger.error(`Ruta de linter no válida: ${path}`);
212
- return false;
213
- }
214
- }
215
- }
216
- if (linter.fix !== undefined && typeof linter.fix !== 'boolean') {
217
- logger.error('Linter fix debe ser un booleano');
218
- return false;
219
- }
220
- return true;
221
- }
222
- /**
223
- * Valida el tamaño del objeto de configuración
224
- */
225
- static validateConfigSize(config) {
226
- try {
227
- const configString = JSON.stringify(config);
228
- if (configString.length > this.MAX_CONFIG_SIZE) {
229
- logger.error(`Configuración demasiado grande: ${configString.length} bytes`);
230
- return false;
231
- }
232
- return true;
233
- }
234
- catch (error) {
235
- logger.error('Error al serializar configuración (posible referencia circular):', error);
236
- return false;
237
- }
238
- }
239
- }
240
- /**
241
- * Limpia y normaliza una ruta eliminando barras finales
242
- */
243
- function cleanPath(path) {
244
- if (!path || typeof path !== 'string') {
245
- return '';
246
- }
247
- return path.endsWith('/') || path.endsWith('\\') ? path.slice(0, -1) : path;
248
- }
249
- /**
250
- * Serializa de forma segura un objeto a JSON
251
- */
252
- function safeJsonStringify(obj, fallback = 'false') {
253
- try {
254
- if (obj === null || obj === undefined) {
255
- return fallback;
256
- }
257
- return JSON.stringify(obj);
258
- }
259
- catch (error) {
260
- logger.warn('Error al serializar objeto, usando valor por defecto:', error);
261
- return fallback;
262
- }
263
- }
264
- /**
265
- * Wrapper para el import dinámico que permite mejor testing
266
- */
267
- export async function dynamicImport(url) {
268
- return import(url);
269
- }
270
- /**
271
- * Timeout wrapper para promises
272
- */
273
- export function withTimeout(promise, timeoutMs, errorMessage) {
274
- const timeoutPromise = new Promise((resolve, reject) => setTimeout(() => reject(new Error(errorMessage)), timeoutMs));
275
- return Promise.race([promise, timeoutPromise]);
276
- }
277
- /**
278
- * Lee y valida el archivo de configuración de forma segura
279
- */
280
- export async function readConfig() {
281
- try {
282
- // Validar variable de entorno
283
- if (!env.PATH_CONFIG_FILE) {
284
- throw new Error('La variable de entorno PATH_CONFIG_FILE no está definida.');
285
- }
286
- // Validar la ruta del archivo de configuración
287
- if (!SecurityValidators.validatePath(env.PATH_CONFIG_FILE)) {
288
- throw new Error(`Ruta de configuración no válida: ${env.PATH_CONFIG_FILE}`);
289
- }
290
- // Convertir la ruta del archivo a una URL file://
291
- const configFileUrl = pathToFileURL(env.PATH_CONFIG_FILE).href;
292
- // Importar con timeout para prevenir ataques DoS
293
- const importPromise = dynamicImport(configFileUrl);
294
- const data = await withTimeout(importPromise, 10000, 'Timeout al cargar configuración');
295
- if (!data) {
296
- throw new Error('No se pudo leer el archivo de configuración.');
297
- }
298
- const tsConfig = data.default || data;
299
- // Validar tamaño de configuración
300
- if (!SecurityValidators.validateConfigSize(tsConfig)) {
301
- throw new Error('Configuración demasiado grande o contiene referencias circulares.');
302
- }
303
- // Validar estructura de configuración
304
- if (!SecurityValidators.validateConfigStructure(tsConfig)) {
305
- throw new Error('El archivo de configuración no tiene una estructura válida.');
306
- }
307
- // Procesar pathsAlias de forma segura
308
- const pathAlias = { ...tsConfig.compilerOptions.pathsAlias }; // Eliminar /* de las rutas de alias
309
- for (const key in pathAlias) {
310
- const values = pathAlias[key];
311
- if (values && Array.isArray(values)) {
312
- for (let i = 0; i < values.length; i++) {
313
- if (typeof values[i] === 'string' &&
314
- values[i] !== undefined) {
315
- values[i] = values[i].replace('/*', '');
316
- }
317
- }
318
- }
319
- }
320
- // Establecer variables de entorno de forma segura
321
- env.PATH_ALIAS = safeJsonStringify(pathAlias, '{}');
322
- env.tailwindcss = safeJsonStringify(tsConfig?.tailwindConfig, 'false');
323
- env.proxyUrl = (tsConfig?.proxyConfig?.proxyUrl || '').toString();
324
- env.AssetsOmit = (tsConfig?.proxyConfig?.assetsOmit || false).toString();
325
- env.linter = safeJsonStringify(tsConfig?.linter, 'false');
326
- env.tsconfigFile = tsConfig?.tsconfig || './tsconfig.json';
327
- // Validar y limpiar rutas
328
- const sourceRoot = cleanPath(tsConfig?.compilerOptions?.sourceRoot || './src');
329
- const outDir = cleanPath(tsConfig?.compilerOptions?.outDir || './dist');
330
- if (!SecurityValidators.validatePath(sourceRoot)) {
331
- throw new Error(`sourceRoot no válido: ${sourceRoot}`);
332
- }
333
- if (!SecurityValidators.validatePath(outDir)) {
334
- throw new Error(`outDir no válido: ${outDir}`);
335
- }
336
- env.PATH_SOURCE = sourceRoot;
337
- env.PATH_DIST = outDir;
338
- env.aditionalWatch = safeJsonStringify(tsConfig?.aditionalWatch, '[]');
339
- env.bundlers = safeJsonStringify(tsConfig?.bundlers, 'false');
340
- // Configuración adicional para compatibilidad
341
- if (!tsConfig.compilerOptions.sourceRoot) {
342
- env.tsConfig = safeJsonStringify(tsConfig, '{}');
343
- }
344
- logger.info('✅ Configuration loaded and validated successfully');
345
- return true;
346
- }
347
- catch (error) {
348
- logger.error(`🚩 Error al leer el archivo ${env.PATH_CONFIG_FILE}: ${error}`, error);
349
- return false;
350
- }
351
- }
352
- /**
353
- * Inicializa un archivo de configuración seguro por defecto
354
- */
355
- export async function initConfig() {
356
- try {
357
- const fs = await dynamicImport('fs');
358
- const path = await dynamicImport('path');
359
- const configPath = path.resolve(process.cwd(), env.PATH_CONFIG_FILE || 'versacompile.config.ts');
360
- // Validar que la ruta de destino sea segura
361
- if (!SecurityValidators.validatePath(configPath)) {
362
- throw new Error(`Ruta de configuración no válida: ${configPath}`);
363
- }
364
- if (fs.existsSync(configPath)) {
365
- logger.warn(`🚩 El archivo de configuración '${env.PATH_CONFIG_FILE}' ya existe.`);
366
- return true;
367
- }
368
- const configContent = `// Archivo de configuración de VersaCompiler
369
- export default {
370
- tsconfig: './tsconfig.json',
371
- compilerOptions: {
372
- sourceRoot: './src',
373
- outDir: './dist',
374
- pathsAlias: {
375
- '/dist/examples/*': ['src/*'],
376
- '/dist/public/*': ['public/*'],
377
- },
378
- },
379
- proxyConfig: {
380
- proxyUrl: '',
381
- assetsOmit: true,
382
- },
383
- aditionalWatch: ['./app/templates/**/*.twig', './app/templates/**/*.html'],
384
- // puede dejar en false o no agregarlo si no quiere que se ejecute el compilador de tailwind
385
- tailwindConfig: {
386
- bin: './node_modules/.bin/tailwindcss',
387
- input: './src/css/input.css',
388
- output: './public/css/output.css',
389
- },
390
- linter: [
391
- {
392
- name: 'eslint',
393
- bin: './node_modules/.bin/eslint',
394
- configFile: './.eslintrc.json',
395
- fix: false,
396
- paths: ['src/']
397
- },
398
- {
399
- name: 'oxlint',
400
- bin: './node_modules/.bin/oxlint',
401
- configFile: './.oxlintrc.json',
402
- fix: false,
403
- paths: ['src/']
404
- },
405
- ],
406
- // Configuración de bundlers
407
- bundlers: [
408
- {
409
- name: 'appLoader',
410
- fileInput: './public/module/appLoader.js',
411
- fileOutput: './public/module/appLoader.prod.js',
412
- },
413
- {
414
- name: 'mainApp',
415
- fileInput: './src/main.ts',
416
- fileOutput: './dist/main.bundle.js',
417
- }
418
- ],
419
- };
420
- `;
421
- fs.writeFileSync(configPath, configContent, 'utf8');
422
- logger.info(`🚩 Archivo de configuración '${env.PATH_CONFIG_FILE}' creado correctamente.`);
423
- return true;
424
- }
425
- catch (error) {
426
- logger.error(`🚩 Error al crear el archivo de configuración: ${error}`, error);
427
- return false;
428
- }
429
- }
430
- //# sourceMappingURL=readConfig.js.map
1
+ import{normalize as e,relative as d,resolve as f}from"node:path";import*as p from"node:process";import{env as m}from"node:process";import{pathToFileURL as h}from"node:url";import{logger as g}from"./logger.js";const _=260,v=1024*1024,y=/^[a-zA-Z0-9.\-_/\\:@ ()[\]]+$/,b=[/\.\./,/[;&|`$]/,/\$\(/,/`.*`/,/\|\s*[a-zA-Z]/];export function validatePath(m){if(!m||typeof m!=`string`)return!1;if(m.length>260)return g.warn(`Ruta demasiado larga: ${m.length} caracteres`),!1;let h=e(m),_=f(p.cwd(),h),v=d(p.cwd(),_);return v.startsWith(`..`)||h.includes(`..`)?(g.error(`Detectado intento de path traversal: ${m}`),!1):y.test(m)?!0:(g.error(`Caracteres no permitidos en la ruta: ${m}`),!1)}export function validateCommand(e){if(!e||typeof e!=`string`)return!1;if(e.length>260)return g.warn(`Comando demasiado largo: ${e.length} caracteres`),!1;for(let d of b)if(d.test(e))return g.error(`Detectado patrón peligroso en comando: ${e}`),!1;let d=[`.exe`,`.cmd`,`.bat`,`.sh`,`.js`,`.ts`],f=d.some(d=>e.toLowerCase().includes(d)||e.startsWith(`./node_modules/.bin/`)||e.startsWith(`npx `));return f?!0:(g.error(`Comando no permitido: ${e}`),!1)}export function validateBundlers(e){if(!Array.isArray(e))return g.error(`bundlers debe ser un array`),!1;for(let d of e){if(!d||typeof d!=`object`)return g.error(`Cada entrada de bundler debe ser un objeto`),!1;if(!d.name||typeof d.name!=`string`)return g.error(`Cada entrada de bundler debe tener un nombre válido`),!1;if(!d.fileInput||typeof d.fileInput!=`string`)return g.error(`Cada entrada de bundler debe tener un fileInput válido`),!1;if(!validatePath(d.fileInput))return g.error(`Ruta de entrada no válida: ${d.fileInput}`),!1;if(!d.fileOutput||typeof d.fileOutput!=`string`)return g.error(`Cada entrada de bundler debe tener un fileOutput válido`),!1;if(!validatePath(d.fileOutput))return g.error(`Ruta de salida no válida: ${d.fileOutput}`),!1}return!0}export function validateConfigStructure(e){if(!e||typeof e!=`object`)return g.error(`La configuración debe ser un objeto`),!1;if(!e.compilerOptions||typeof e.compilerOptions!=`object`)return g.error(`compilerOptions es requerido y debe ser un objeto`),!1;if(!e.compilerOptions.pathsAlias||typeof e.compilerOptions.pathsAlias!=`object`)return g.error(`pathsAlias es requerido y debe ser un objeto`),!1;for(let[d,f]of Object.entries(e.compilerOptions.pathsAlias)){if(!Array.isArray(f))return g.error(`pathsAlias["${d}"] debe ser un array`),!1;for(let e of f){if(typeof e!=`string`)return g.error(`Todas las rutas en pathsAlias["${d}"] deben ser strings`),!1;if(!validatePath(e.replace(`/*`,``)))return g.error(`Ruta no válida en pathsAlias["${d}"]: ${e}`),!1}}if(e.compilerOptions.sourceRoot&&!validatePath(e.compilerOptions.sourceRoot)||e.compilerOptions.outDir&&!validatePath(e.compilerOptions.outDir))return!1;if(e.linter&&e.linter!==!1){if(!Array.isArray(e.linter))return g.error(`linter debe ser un array o false`),!1;for(let d of e.linter)if(!validateLinter(d))return!1}return!0}export function validateLinter(e){if(!e||typeof e!=`object`)return g.error(`Cada linter debe ser un objeto`),!1;if(!e.name||typeof e.name!=`string`)return g.error(`Linter debe tener un nombre válido`),!1;if(!e.bin||typeof e.bin!=`string`)return g.error(`Linter debe tener un bin válido`),!1;if(!validateCommand(e.bin))return!1;if(!e.configFile||typeof e.configFile!=`string`)return g.error(`Linter debe tener un configFile válido`),!1;if(!validatePath(e.configFile))return!1;if(e.paths&&!Array.isArray(e.paths))return g.error(`linter.paths debe ser un array`),!1;if(e.paths){for(let d of e.paths)if(typeof d!=`string`||!validatePath(d))return g.error(`Ruta de linter no válida: ${d}`),!1}return e.fix!==void 0&&typeof e.fix!=`boolean`?(g.error(`Linter fix debe ser un booleano`),!1):!0}export function validateConfigSize(e){try{let d=JSON.stringify(e);return d.length>1048576?(g.error(`Configuración demasiado grande: ${d.length} bytes`),!1):!0}catch(e){return g.error(`Error al serializar configuración (posible referencia circular):`,e),!1}}function x(e){return!e||typeof e!=`string`?``:e.endsWith(`/`)||e.endsWith(`\\`)?e.slice(0,-1):e}function S(e,d=`false`){try{return e==null?d:JSON.stringify(e)}catch(e){return g.warn(`Error al serializar objeto, usando valor por defecto:`,e),d}}export async function dynamicImport(e){return import(e)}export function withTimeout(e,d,f){let p=new Promise((e,p)=>setTimeout(()=>p(Error(f)),d));return Promise.race([e,p])}export async function readConfig(){try{if(!m.PATH_CONFIG_FILE)throw Error(`La variable de entorno PATH_CONFIG_FILE no está definida.`);if(!validatePath(m.PATH_CONFIG_FILE))throw Error(`Ruta de configuración no válida: ${m.PATH_CONFIG_FILE}`);let e=h(m.PATH_CONFIG_FILE).href,d=dynamicImport(e),f=await withTimeout(d,1e4,`Timeout al cargar configuración`);if(!f)throw Error(`No se pudo leer el archivo de configuración.`);let p=f.default||f;if(!validateConfigSize(p))throw Error(`Configuración demasiado grande o contiene referencias circulares.`);if(!validateConfigStructure(p))throw Error(`El archivo de configuración no tiene una estructura válida.`);let _={...p.compilerOptions.pathsAlias};for(let e in _){let d=_[e];if(d&&Array.isArray(d))for(let e=0;e<d.length;e++)typeof d[e]==`string`&&d[e]!==void 0&&(d[e]=d[e].replace(`/*`,``))}m.PATH_ALIAS=S(_,`{}`),m.tailwindcss=S(p?.tailwindConfig,`false`),m.proxyUrl=String(p?.proxyConfig?.proxyUrl||``),m.AssetsOmit=String(p?.proxyConfig?.assetsOmit||!1),m.linter=S(p?.linter,`false`),m.tsconfigFile=p?.tsconfig||`./tsconfig.json`;let v=x(p?.compilerOptions?.sourceRoot||`./src`),y=x(p?.compilerOptions?.outDir||`./dist`);if(!validatePath(v))throw Error(`sourceRoot no válido: ${v}`);if(!validatePath(y))throw Error(`outDir no válido: ${y}`);return m.PATH_SOURCE=v,m.PATH_DIST=y,m.aditionalWatch=S(p?.aditionalWatch,`[]`),m.bundlers=S(p?.bundlers,`false`),p.compilerOptions.sourceRoot||(m.tsConfig=S(p,`{}`)),g.info(`✅ Configuration loaded and validated successfully`),!0}catch(e){return g.error(`🚩 Error al leer el archivo ${m.PATH_CONFIG_FILE}: ${e}`,e),!1}}export async function initConfig(){try{let e=await dynamicImport(`fs`),d=await dynamicImport(`path`),f=d.resolve(p.cwd(),m.PATH_CONFIG_FILE||`versacompile.config.ts`);if(!validatePath(f))throw Error(`Ruta de configuración no válida: ${f}`);if(e.existsSync(f))return g.warn(`🚩 El archivo de configuración '${m.PATH_CONFIG_FILE}' ya existe.`),!0;let h=`// Archivo de configuración de VersaCompiler
2
+ export default {
3
+ tsconfig: './tsconfig.json',
4
+ compilerOptions: {
5
+ sourceRoot: './src',
6
+ outDir: './dist',
7
+ pathsAlias: {
8
+ '/dist/examples/*': ['src/*'],
9
+ '/dist/public/*': ['public/*'],
10
+ },
11
+ },
12
+ proxyConfig: {
13
+ proxyUrl: '',
14
+ assetsOmit: true,
15
+ },
16
+ aditionalWatch: ['./app/templates/**/*.twig', './app/templates/**/*.html'],
17
+ // puede dejar en false o no agregarlo si no quiere que se ejecute el compilador de tailwind
18
+ tailwindConfig: {
19
+ bin: './node_modules/.bin/tailwindcss',
20
+ input: './src/css/input.css',
21
+ output: './public/css/output.css',
22
+ },
23
+ linter: [
24
+ {
25
+ name: 'eslint',
26
+ bin: './node_modules/.bin/eslint',
27
+ configFile: './.eslintrc.json',
28
+ fix: false,
29
+ paths: ['src/']
30
+ },
31
+ {
32
+ name: 'oxlint',
33
+ bin: './node_modules/.bin/oxlint',
34
+ configFile: './.oxlintrc.json',
35
+ fix: false,
36
+ paths: ['src/']
37
+ },
38
+ ],
39
+ // Configuración de bundlers
40
+ bundlers: [
41
+ {
42
+ name: 'appLoader',
43
+ fileInput: './public/module/appLoader.js',
44
+ fileOutput: './public/module/appLoader.prod.js',
45
+ },
46
+ {
47
+ name: 'mainApp',
48
+ fileInput: './src/main.ts',
49
+ fileOutput: './dist/main.bundle.js',
50
+ }
51
+ ],
52
+ };
53
+ `;return e.writeFileSync(f,`// Archivo de configuración de VersaCompiler
54
+ export default {
55
+ tsconfig: './tsconfig.json',
56
+ compilerOptions: {
57
+ sourceRoot: './src',
58
+ outDir: './dist',
59
+ pathsAlias: {
60
+ '/dist/examples/*': ['src/*'],
61
+ '/dist/public/*': ['public/*'],
62
+ },
63
+ },
64
+ proxyConfig: {
65
+ proxyUrl: '',
66
+ assetsOmit: true,
67
+ },
68
+ aditionalWatch: ['./app/templates/**/*.twig', './app/templates/**/*.html'],
69
+ // puede dejar en false o no agregarlo si no quiere que se ejecute el compilador de tailwind
70
+ tailwindConfig: {
71
+ bin: './node_modules/.bin/tailwindcss',
72
+ input: './src/css/input.css',
73
+ output: './public/css/output.css',
74
+ },
75
+ linter: [
76
+ {
77
+ name: 'eslint',
78
+ bin: './node_modules/.bin/eslint',
79
+ configFile: './.eslintrc.json',
80
+ fix: false,
81
+ paths: ['src/']
82
+ },
83
+ {
84
+ name: 'oxlint',
85
+ bin: './node_modules/.bin/oxlint',
86
+ configFile: './.oxlintrc.json',
87
+ fix: false,
88
+ paths: ['src/']
89
+ },
90
+ ],
91
+ // Configuración de bundlers
92
+ bundlers: [
93
+ {
94
+ name: 'appLoader',
95
+ fileInput: './public/module/appLoader.js',
96
+ fileOutput: './public/module/appLoader.prod.js',
97
+ },
98
+ {
99
+ name: 'mainApp',
100
+ fileInput: './src/main.ts',
101
+ fileOutput: './dist/main.bundle.js',
102
+ }
103
+ ],
104
+ };
105
+ `,`utf8`),g.info(`🚩 Archivo de configuración '${m.PATH_CONFIG_FILE}' creado correctamente.`),!0}catch(e){return g.error(`🚩 Error al crear el archivo de configuración: ${e}`,e),!1}}
@@ -1,36 +1 @@
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
1
+ export const EXCLUDED_MODULES=new Set([`vue/compiler-sfc`,`vue/dist/vue.runtime.esm-bundler`,`@vue/compiler-sfc`,`@vue/compiler-dom`,`@vue/runtime-core`,`@vue/runtime-dom`,`oxc-parser`,`oxc-parser/wasm`,`oxc-minify`,`oxc-minify/browser`,`@oxc-parser/binding-wasm32-wasi`,`@oxc-minify/binding-wasm32-wasi`,`typescript`,`typescript/lib/typescript`,`yargs`,`yargs/helpers`,`yargs-parser`,`chalk`,`browser-sync`,`chokidar`,`get-port`,`execa`,`find-root`,`fs-extra`,`minimatch`]);