versacompiler 2.0.6 → 2.0.7
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/typescript-manager.js +27 -5
- package/dist/main.js +16 -1
- package/dist/servicios/browserSync.js +24 -12
- package/package.json +11 -11
|
@@ -164,6 +164,30 @@ export const validateVueTypes = (vueContent, fileName, options) => {
|
|
|
164
164
|
return validateTypesWithLanguageService(fileName, scriptContent, // Usar solo el contenido del script
|
|
165
165
|
compilerOptions);
|
|
166
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Limpia los export {} innecesarios que TypeScript agrega automáticamente
|
|
169
|
+
* @param compiledOutput - Código JavaScript compilado
|
|
170
|
+
* @param originalSource - Código TypeScript original
|
|
171
|
+
* @returns Código limpio sin export {} innecesarios
|
|
172
|
+
*/
|
|
173
|
+
const cleanupUnnecessaryExports = (compiledOutput, originalSource) => {
|
|
174
|
+
// Si el output está vacío o solo contiene export {}
|
|
175
|
+
if (compiledOutput.trim() === 'export {};') {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
// Verificar si el código fuente original tiene imports/exports reales
|
|
179
|
+
const hasRealImportsExports = /(?:^|\s)(?:import|export)\s+(?!(?:\s*\{\s*\}\s*;?\s*$))/m.test(originalSource);
|
|
180
|
+
// Si no hay imports/exports reales, eliminar export {} del final
|
|
181
|
+
if (!hasRealImportsExports) {
|
|
182
|
+
// Buscar el patrón exacto en el archivo
|
|
183
|
+
const exportPattern = /export\s*\{\s*\}\s*;\s*$/m;
|
|
184
|
+
const hasExportAtEnd = exportPattern.test(compiledOutput);
|
|
185
|
+
if (hasExportAtEnd) {
|
|
186
|
+
return compiledOutput.replace(exportPattern, '');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return compiledOutput;
|
|
190
|
+
};
|
|
167
191
|
/**
|
|
168
192
|
* Precompila el código TypeScript con pipeline optimizado para máxima performance.
|
|
169
193
|
* @param {string} data - El código TypeScript a precompilar.
|
|
@@ -233,11 +257,9 @@ export const preCompileTS = async (data, fileName) => {
|
|
|
233
257
|
}
|
|
234
258
|
}
|
|
235
259
|
// PASO 3: Devolver resultado optimizado
|
|
236
|
-
|
|
237
|
-
// Limpiar
|
|
238
|
-
|
|
239
|
-
return { error: null, data: '', lang: 'ts' };
|
|
240
|
-
}
|
|
260
|
+
let output = transpileResult.outputText;
|
|
261
|
+
// Limpiar export {} innecesarios
|
|
262
|
+
output = cleanupUnnecessaryExports(output, data);
|
|
241
263
|
return { error: null, data: output, lang: 'ts' };
|
|
242
264
|
}
|
|
243
265
|
catch (error) {
|
package/dist/main.js
CHANGED
|
@@ -19,6 +19,20 @@ async function loadChalk() {
|
|
|
19
19
|
}
|
|
20
20
|
return chalk;
|
|
21
21
|
}
|
|
22
|
+
// Función para obtener la versión del package.json
|
|
23
|
+
async function getPackageVersion() {
|
|
24
|
+
try {
|
|
25
|
+
const fs = await import('node:fs/promises');
|
|
26
|
+
const packageJsonPath = path.resolve(env.PATH_PROY || path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
27
|
+
const packageContent = await fs.readFile(packageJsonPath, 'utf-8');
|
|
28
|
+
const packageData = JSON.parse(packageContent);
|
|
29
|
+
return packageData.version || 'unknown';
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Fallback si no se puede leer el package.json
|
|
33
|
+
return 'unknown';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
22
36
|
async function loadYargs() {
|
|
23
37
|
if (!yargs) {
|
|
24
38
|
const yargsModule = await import('yargs');
|
|
@@ -133,12 +147,13 @@ async function main() {
|
|
|
133
147
|
.parse());
|
|
134
148
|
try {
|
|
135
149
|
// 🎨 Header moderno y elegante
|
|
150
|
+
const version = await getPackageVersion();
|
|
136
151
|
const headerLine = '━'.repeat(60);
|
|
137
152
|
logger.log(`\n` +
|
|
138
153
|
chalk.cyan(headerLine) +
|
|
139
154
|
`\n` +
|
|
140
155
|
chalk.bold.cyan(' ⚡ VersaCompiler ') +
|
|
141
|
-
chalk.gray(
|
|
156
|
+
chalk.gray(`v${version}`) +
|
|
142
157
|
`\n` +
|
|
143
158
|
chalk.gray(' Vue · TypeScript · JavaScript Compiler') +
|
|
144
159
|
`\n` +
|
|
@@ -373,10 +373,14 @@ export async function browserSyncServer() {
|
|
|
373
373
|
if (cachedFile) {
|
|
374
374
|
res.setHeader('Content-Type', cachedFile.contentType);
|
|
375
375
|
res.setHeader('ETag', cachedFile.etag);
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
376
|
+
// if (
|
|
377
|
+
// process.env.VERBOSE === 'true' &&
|
|
378
|
+
// cachedFile.cached
|
|
379
|
+
// ) {
|
|
380
|
+
// logger.info(
|
|
381
|
+
// `🚀 File cache hit para ${vueLoaderPath}`,
|
|
382
|
+
// );
|
|
383
|
+
// }
|
|
380
384
|
res.end(cachedFile.content);
|
|
381
385
|
}
|
|
382
386
|
else {
|
|
@@ -395,10 +399,14 @@ export async function browserSyncServer() {
|
|
|
395
399
|
if (cachedFile) {
|
|
396
400
|
res.setHeader('Content-Type', cachedFile.contentType);
|
|
397
401
|
res.setHeader('ETag', cachedFile.etag);
|
|
398
|
-
if (
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
+
// if (
|
|
403
|
+
// process.env.VERBOSE === 'true' &&
|
|
404
|
+
// cachedFile.cached
|
|
405
|
+
// ) {
|
|
406
|
+
// logger.info(
|
|
407
|
+
// `🚀 File cache hit para ${filePath}`,
|
|
408
|
+
// );
|
|
409
|
+
// }
|
|
402
410
|
res.end(cachedFile.content);
|
|
403
411
|
}
|
|
404
412
|
else {
|
|
@@ -417,10 +425,14 @@ export async function browserSyncServer() {
|
|
|
417
425
|
if (cachedFile) {
|
|
418
426
|
res.setHeader('Content-Type', cachedFile.contentType);
|
|
419
427
|
res.setHeader('ETag', cachedFile.etag);
|
|
420
|
-
if (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
428
|
+
// if (
|
|
429
|
+
// process.env.VERBOSE === 'true' &&
|
|
430
|
+
// cachedFile.cached
|
|
431
|
+
// ) {
|
|
432
|
+
// logger.info(
|
|
433
|
+
// `🚀 Module cache hit para ${modulePath}`,
|
|
434
|
+
// );
|
|
435
|
+
// }
|
|
424
436
|
res.end(cachedFile.content);
|
|
425
437
|
}
|
|
426
438
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versacompiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
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": {
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/kriollo/versaCompiler#readme",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@vue/compiler-dom": "^3.5.
|
|
53
|
-
"@vue/reactivity": "^3.5.
|
|
54
|
-
"@vue/runtime-core": "^3.5.
|
|
55
|
-
"@vue/runtime-dom": "^3.5.
|
|
52
|
+
"@vue/compiler-dom": "^3.5.17",
|
|
53
|
+
"@vue/reactivity": "^3.5.17",
|
|
54
|
+
"@vue/runtime-core": "^3.5.17",
|
|
55
|
+
"@vue/runtime-dom": "^3.5.17",
|
|
56
56
|
"browser-sync": "^3.0.4",
|
|
57
57
|
"chalk": "5.4.1",
|
|
58
58
|
"chokidar": "^4.0.3",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"fs-extra": "^11.3.0",
|
|
63
63
|
"get-port": "^7.1.0",
|
|
64
64
|
"minimatch": "^10.0.1",
|
|
65
|
-
"oxc-minify": "^0.
|
|
66
|
-
"oxc-parser": "^0.
|
|
67
|
-
"oxc-transform": "^0.
|
|
65
|
+
"oxc-minify": "^0.75.0",
|
|
66
|
+
"oxc-parser": "^0.75.0",
|
|
67
|
+
"oxc-transform": "^0.75.0",
|
|
68
68
|
"resolve": "^1.22.10",
|
|
69
69
|
"tsx": "^4.19.4",
|
|
70
70
|
"typescript": "^5.8.3",
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
"eslint-plugin-vue": "^10.2.0",
|
|
97
97
|
"happy-dom": "^18.0.1",
|
|
98
98
|
"jest": "^30.0.0",
|
|
99
|
-
"jest-environment-jsdom": "30.0.
|
|
100
|
-
"jest-environment-node": "30.0.
|
|
99
|
+
"jest-environment-jsdom": "30.0.2",
|
|
100
|
+
"jest-environment-node": "30.0.2",
|
|
101
101
|
"oxlint": "^1.0.0",
|
|
102
|
-
"prettier": "3.
|
|
102
|
+
"prettier": "3.6.2",
|
|
103
103
|
"rimraf": "^6.0.1",
|
|
104
104
|
"sweetalert2": "^11.22.0",
|
|
105
105
|
"tailwindcss": "^4.1.8",
|