versacompiler 1.0.4 → 2.0.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.
- package/README.md +357 -145
- package/dist/compiler/compile.js +1120 -0
- package/dist/compiler/error-reporter.js +467 -0
- package/dist/compiler/linter.js +72 -0
- package/dist/{services → compiler}/minify.js +40 -31
- package/dist/compiler/parser.js +30 -0
- package/dist/compiler/tailwindcss.js +39 -0
- package/dist/compiler/transformTStoJS.js +16 -0
- package/dist/compiler/transforms.js +544 -0
- package/dist/compiler/typescript-error-parser.js +282 -0
- package/dist/compiler/typescript-sync-validator.js +230 -0
- package/dist/compiler/typescript-worker-thread.cjs +457 -0
- package/dist/compiler/typescript-worker.js +309 -0
- package/dist/compiler/typescript.js +382 -0
- package/dist/compiler/vuejs.js +296 -0
- package/dist/hrm/VueHRM.js +353 -0
- package/dist/hrm/errorScreen.js +23 -1
- package/dist/hrm/getInstanciaVue.js +313 -0
- package/dist/hrm/initHRM.js +140 -0
- package/dist/main.js +287 -0
- package/dist/servicios/browserSync.js +177 -0
- package/dist/servicios/chokidar.js +178 -0
- package/dist/servicios/logger.js +33 -0
- package/dist/servicios/readConfig.js +429 -0
- package/dist/utils/module-resolver.js +506 -0
- package/dist/utils/promptUser.js +48 -0
- package/dist/utils/resolve-bin.js +29 -0
- package/dist/utils/utils.js +21 -48
- package/dist/wrappers/eslint-node.js +145 -0
- package/dist/wrappers/oxlint-node.js +120 -0
- package/dist/wrappers/tailwind-node.js +92 -0
- package/package.json +62 -15
- package/dist/hrm/devMode.js +0 -249
- package/dist/hrm/instanciaVue.js +0 -35
- package/dist/hrm/setupHMR.js +0 -57
- package/dist/index.js +0 -873
- package/dist/services/acorn.js +0 -29
- package/dist/services/linter.js +0 -55
- package/dist/services/typescript.js +0 -89
- package/dist/services/vueLoader.js +0 -324
- package/dist/services/vuejs.js +0 -259
package/README.md
CHANGED
|
@@ -1,145 +1,357 @@
|
|
|
1
|
-
#
|
|
2
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|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
1
|
+
# 🚀 VersaCompiler
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://vuejs.org/)
|
|
6
|
+
|
|
7
|
+
> **🎯 Compilador rápido y eficiente para Vue.js, TypeScript y JavaScript con Hot Module Replacement (HMR) integrado.**
|
|
8
|
+
|
|
9
|
+
**VersaCompiler** es una herramienta de compilación diseñada para proyectos Vue 3 con soporte completo para TypeScript, JavaScript y todas las funcionalidades modernas que necesitas para desarrollo web.
|
|
10
|
+
|
|
11
|
+
## 🌟 Características Principales
|
|
12
|
+
|
|
13
|
+
- ⚡ **Compilación rápida** - Compilación paralela optimizada para velocidad
|
|
14
|
+
- 🔥 **Hot Module Replacement (HMR)** - Actualizaciones instantáneas durante desarrollo
|
|
15
|
+
- 🧩 **Soporte completo para Vue 3** - Single File Components (SFC)
|
|
16
|
+
- 📝 **TypeScript nativo** - Transpilación integrada sin configuración adicional
|
|
17
|
+
- 🔍 **Linting dual** - ESLint + OxLint para máxima cobertura
|
|
18
|
+
- 🎨 **TailwindCSS integrado** - Compilación automática de estilos
|
|
19
|
+
- 🗜️ **Minificación avanzada** - OxcMinify para builds optimizados
|
|
20
|
+
- 📦 **Bundling inteligente** - Agrupación de módulos configurable
|
|
21
|
+
|
|
22
|
+
## ⚡ Instalación
|
|
23
|
+
|
|
24
|
+
### 📦 Desde código fuente
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/kriollo/versaCompiler.git
|
|
28
|
+
cd versaCompiler
|
|
29
|
+
npm install
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 🔗 Instalación local en tu proyecto
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Copiar archivos compilados a tu proyecto
|
|
37
|
+
cp -r dist/* tu-proyecto/versacompiler/
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 🎯 Quick Start
|
|
41
|
+
|
|
42
|
+
### 1. Configuración inicial
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Crear archivo de configuración
|
|
46
|
+
versacompiler --init
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Estructura de proyecto
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
mi-proyecto/
|
|
53
|
+
├── src/ # 📝 Código fuente
|
|
54
|
+
│ ├── components/ # 🧩 Componentes Vue
|
|
55
|
+
│ └── main.ts # 🚀 Punto de entrada
|
|
56
|
+
├── dist/ # 📦 Archivos compilados (auto-generado)
|
|
57
|
+
├── versacompile.config.ts # ⚙️ Configuración
|
|
58
|
+
└── package.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Comandos básicos
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 🔥 Desarrollo con auto-reload
|
|
65
|
+
versacompiler --watch
|
|
66
|
+
|
|
67
|
+
# 🏗️ Compilar todo el proyecto
|
|
68
|
+
versacompiler --all
|
|
69
|
+
|
|
70
|
+
# 🚀 Build para producción
|
|
71
|
+
versacompiler --all --prod
|
|
72
|
+
|
|
73
|
+
# 🔍 Solo verificar código (linting)
|
|
74
|
+
versacompiler --lint-only
|
|
75
|
+
|
|
76
|
+
# 🧹 Limpiar y recompilar
|
|
77
|
+
versacompiler --clean --all
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 📖 Configuración
|
|
81
|
+
|
|
82
|
+
### 🛠️ Comandos CLI Disponibles
|
|
83
|
+
|
|
84
|
+
| Comando | Alias | Descripción |
|
|
85
|
+
| ------------- | ----- | -------------------------------- |
|
|
86
|
+
| `--watch` | `-w` | Modo observación con HMR |
|
|
87
|
+
| `--all` | | Compilar todos los archivos |
|
|
88
|
+
| `--prod` | `-p` | Modo producción con minificación |
|
|
89
|
+
| `--clean` | | Limpiar directorio de salida |
|
|
90
|
+
| `--lint-only` | | Solo ejecutar linting |
|
|
91
|
+
| `--verbose` | `-v` | Salida detallada |
|
|
92
|
+
| `--init` | | Inicializar configuración |
|
|
93
|
+
| `--help` | `-h` | Mostrar ayuda |
|
|
94
|
+
|
|
95
|
+
### 🔧 Archivo de configuración
|
|
96
|
+
|
|
97
|
+
Crea un archivo `versacompile.config.ts` en la raíz de tu proyecto:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// Archivo de configuración de VersaCompiler
|
|
101
|
+
export default {
|
|
102
|
+
tsconfig: './tsconfig.json',
|
|
103
|
+
compilerOptions: {
|
|
104
|
+
sourceRoot: './src',
|
|
105
|
+
outDir: './dist',
|
|
106
|
+
pathsAlias: {
|
|
107
|
+
'@/*': ['src/*'],
|
|
108
|
+
'P@/*': ['public/*'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
proxyConfig: {
|
|
112
|
+
proxyUrl: '',
|
|
113
|
+
assetsOmit: true,
|
|
114
|
+
},
|
|
115
|
+
aditionalWatch: ['./app/templates/**/*.twig'],
|
|
116
|
+
tailwindConfig: {
|
|
117
|
+
bin: './node_modules/.bin/tailwindcss',
|
|
118
|
+
input: './src/css/input.css',
|
|
119
|
+
output: './public/css/output.css',
|
|
120
|
+
},
|
|
121
|
+
linter: [
|
|
122
|
+
{
|
|
123
|
+
name: 'eslint',
|
|
124
|
+
bin: './node_modules/.bin/eslint',
|
|
125
|
+
configFile: './eslint.config.js',
|
|
126
|
+
fix: false,
|
|
127
|
+
paths: ['src/'],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'oxlint',
|
|
131
|
+
bin: './node_modules/.bin/oxlint',
|
|
132
|
+
configFile: './.oxlintrc.json',
|
|
133
|
+
fix: false,
|
|
134
|
+
paths: ['src/'],
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
bundlers: [
|
|
138
|
+
{
|
|
139
|
+
name: 'appLoader',
|
|
140
|
+
fileInput: './public/module/appLoader.js',
|
|
141
|
+
fileOutput: './public/module/appLoader.prod.js',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 📝 Opciones de configuración
|
|
148
|
+
|
|
149
|
+
#### `compilerOptions`
|
|
150
|
+
|
|
151
|
+
- `sourceRoot`: Directorio de archivos fuente (por defecto: `'./src'`)
|
|
152
|
+
- `outDir`: Directorio de salida (por defecto: `'./dist'`)
|
|
153
|
+
- `pathsAlias`: Aliases para imports (ej: `'@/*': ['src/*']`)
|
|
154
|
+
|
|
155
|
+
#### `proxyConfig`
|
|
156
|
+
|
|
157
|
+
- `proxyUrl`: URL del proxy para desarrollo
|
|
158
|
+
- `assetsOmit`: Omitir assets en el proxy
|
|
159
|
+
|
|
160
|
+
#### `tailwindConfig`
|
|
161
|
+
|
|
162
|
+
- `bin`: Ruta al binario de TailwindCSS
|
|
163
|
+
- `input`: Archivo CSS de entrada
|
|
164
|
+
- `output`: Archivo CSS de salida
|
|
165
|
+
|
|
166
|
+
#### `linter`
|
|
167
|
+
|
|
168
|
+
Array de configuraciones de linters:
|
|
169
|
+
|
|
170
|
+
- `name`: Nombre del linter (`'eslint'` o `'oxlint'`)
|
|
171
|
+
- `bin`: Ruta al binario del linter
|
|
172
|
+
- `configFile`: Archivo de configuración del linter
|
|
173
|
+
- `fix`: Auto-fix de errores
|
|
174
|
+
- `paths`: Rutas a analizar
|
|
175
|
+
|
|
176
|
+
#### `bundlers`
|
|
177
|
+
|
|
178
|
+
Array de configuraciones de bundling:
|
|
179
|
+
|
|
180
|
+
- `name`: Nombre del bundle
|
|
181
|
+
- `fileInput`: Archivo de entrada
|
|
182
|
+
- `fileOutput`: Archivo de salida
|
|
183
|
+
|
|
184
|
+
## 🎯 Ejemplos de Uso
|
|
185
|
+
|
|
186
|
+
### Desarrollo Local
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Iniciar servidor de desarrollo
|
|
190
|
+
versacompiler --watch
|
|
191
|
+
|
|
192
|
+
# Con verbose para debugging
|
|
193
|
+
versacompiler --watch --verbose
|
|
194
|
+
|
|
195
|
+
# Solo linting durante desarrollo
|
|
196
|
+
versacompiler --lint-only
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Compilación para Producción
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Build completo para producción
|
|
203
|
+
versacompiler --all --prod --clean
|
|
204
|
+
|
|
205
|
+
# Con análisis detallado
|
|
206
|
+
versacompiler --all --prod --verbose
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Integración CI/CD
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Pipeline de CI
|
|
213
|
+
versacompiler --lint-only # Verificar código
|
|
214
|
+
versacompiler --all --prod # Build para producción
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## 🏗️ Funcionalidades
|
|
218
|
+
|
|
219
|
+
### 🔥 Hot Module Replacement (HMR)
|
|
220
|
+
|
|
221
|
+
- **Componentes Vue**: Actualizaciones instantáneas preservando estado
|
|
222
|
+
- **TypeScript/JavaScript**: Recarga inteligente de módulos
|
|
223
|
+
- **CSS/TailwindCSS**: Inyección de estilos sin recarga
|
|
224
|
+
|
|
225
|
+
### 🚀 Compilación Paralela
|
|
226
|
+
|
|
227
|
+
- **Pool de workers optimizado** basado en CPU cores
|
|
228
|
+
- **Cache inteligente** evita recompilaciones innecesarias
|
|
229
|
+
- **Progress bar visual** con métricas en tiempo real
|
|
230
|
+
|
|
231
|
+
### 🔍 Sistema de Linting Dual
|
|
232
|
+
|
|
233
|
+
- **ESLint**: Análisis de código JavaScript/TypeScript
|
|
234
|
+
- **OxLint**: Linter ultra-rápido escrito en Rust
|
|
235
|
+
- **Auto-fix**: Corrección automática de problemas
|
|
236
|
+
|
|
237
|
+
### 📦 Minificación Optimizada
|
|
238
|
+
|
|
239
|
+
- **OxcMinify**: Minificador de última generación
|
|
240
|
+
- **Tree shaking**: Eliminación de código no utilizado
|
|
241
|
+
- **Compresión avanzada**: Optimización de tamaño
|
|
242
|
+
|
|
243
|
+
## 🚧 Troubleshooting
|
|
244
|
+
|
|
245
|
+
### ❌ Problemas Frecuentes
|
|
246
|
+
|
|
247
|
+
#### 🔍 Error: "Cannot resolve module"
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Verificar configuración de aliases
|
|
251
|
+
versacompiler --verbose
|
|
252
|
+
|
|
253
|
+
# Limpiar cache si persiste
|
|
254
|
+
versacompiler --clean
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### 🔥 HMR no funciona
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
// Verificar configuración en versacompile.config.ts
|
|
261
|
+
export default {
|
|
262
|
+
proxyConfig: {
|
|
263
|
+
proxyUrl: '', // Vacío si no usas proxy
|
|
264
|
+
assetsOmit: true,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### 🐌 Linting muy lento
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Usar solo OxLint para máxima velocidad
|
|
273
|
+
versacompiler --lint-only --verbose
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## 📚 Documentación
|
|
277
|
+
|
|
278
|
+
- 📖 [**Guía de Inicio Rápido**](./docs/getting-started.md)
|
|
279
|
+
- 📋 [**Configuración Avanzada**](./docs/configuration.md)
|
|
280
|
+
- 🎯 [**Ejemplos y Recetas**](./docs/examples.md)
|
|
281
|
+
- 🔧 [**API Reference**](./docs/api.md)
|
|
282
|
+
- 🔄 [**Guía de Migración**](./docs/migration.md)
|
|
283
|
+
- 🤝 [**Guía de Contribución**](./docs/contributing.md)
|
|
284
|
+
- ❓ [**FAQ - Preguntas Frecuentes**](./docs/faq.md)
|
|
285
|
+
|
|
286
|
+
## 🧪 Testing
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Ejecutar tests
|
|
290
|
+
npm test
|
|
291
|
+
|
|
292
|
+
# Tests con coverage
|
|
293
|
+
npm run test:coverage
|
|
294
|
+
|
|
295
|
+
# Tests en modo watch
|
|
296
|
+
npm run test:watch
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## 🤝 Contribuir
|
|
300
|
+
|
|
301
|
+
¡Las contribuciones son bienvenidas! Ver [CONTRIBUTING.md](./docs/contributing.md) para detalles.
|
|
302
|
+
|
|
303
|
+
### 🛠️ Desarrollo Local
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
git clone https://github.com/kriollo/versaCompiler.git
|
|
307
|
+
cd versaCompiler
|
|
308
|
+
npm install
|
|
309
|
+
npm run dev
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## 📄 Licencia
|
|
313
|
+
|
|
314
|
+
MIT © [Jorge Jara H](https://github.com/kriollo)
|
|
315
|
+
|
|
316
|
+
## 🙏 Agradecimientos
|
|
317
|
+
|
|
318
|
+
- **Vue.js Team** - Por el increíble framework
|
|
319
|
+
- **TypeScript Team** - Por el excelente sistema de tipos
|
|
320
|
+
- **Oxc Project** - Por las herramientas de desarrollo ultra-rápidas
|
|
321
|
+
- **Comunidad Open Source** - Por el feedback y contribuciones
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## 🔧 Arquitectura Técnica
|
|
326
|
+
|
|
327
|
+
### Compilación de Archivos
|
|
328
|
+
|
|
329
|
+
- **JavaScript**: Compila archivos `.js` y los coloca en el directorio configurado
|
|
330
|
+
- **TypeScript**: Transpila archivos `.ts` a `.js` utilizando las opciones definidas en `tsconfig.json`
|
|
331
|
+
- **Vue**: Procesa archivos `.vue`, compila sus scripts, plantillas y estilos
|
|
332
|
+
|
|
333
|
+
### Minificación
|
|
334
|
+
|
|
335
|
+
Si se ejecuta con el parámetro `--prod`, el código se minifica utilizando `OxcMinify`.
|
|
336
|
+
|
|
337
|
+
### Observación de Archivos
|
|
338
|
+
|
|
339
|
+
El compilador observa los cambios en los archivos `.js`, `.ts` y `.vue` en el directorio `src` y recompila automáticamente los archivos modificados.
|
|
340
|
+
|
|
341
|
+
### Dependencias Principales
|
|
342
|
+
|
|
343
|
+
- **VueJS**: API (vue/compiler-sfc) para compilar archivos .vue
|
|
344
|
+
- **TypeScript**: API (transpileModule) para transpilar TypeScript
|
|
345
|
+
- **OxcMinify**: API (minify) para minificar código
|
|
346
|
+
- **Acorn**: API (Parser) para validar sintaxis
|
|
347
|
+
- **BrowserSync**: API (browserSync) para servidor HMR
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
<div align="center">
|
|
352
|
+
|
|
353
|
+
**¿Te gusta VersaCompiler? ¡Dale una ⭐ en GitHub!**
|
|
354
|
+
|
|
355
|
+
[🐛 Reportar Bug](https://github.com/kriollo/versaCompiler/issues) • [✨ Feature Request](https://github.com/kriollo/versaCompiler/issues) • [💬 Discusiones](https://github.com/kriollo/versaCompiler/discussions)
|
|
356
|
+
|
|
357
|
+
</div>
|