versacompiler 2.3.1 → 2.3.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/minify.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { minifySync } from 'oxc-minify';
|
|
3
|
+
import { logger } from '../servicios/logger.js';
|
|
3
4
|
import { minifyTemplate } from './minifyTemplate.js';
|
|
4
5
|
class MinificationCache {
|
|
5
6
|
static instance;
|
|
@@ -49,11 +50,18 @@ class MinificationCache {
|
|
|
49
50
|
this.cacheMisses++;
|
|
50
51
|
const originalSize = data.length;
|
|
51
52
|
try {
|
|
52
|
-
const result =
|
|
53
|
+
const result = minifySync(filename, data, options);
|
|
53
54
|
// Si el código de entrada no estaba vacío pero el resultado sí,
|
|
54
55
|
// retornar código original sin minificar con advertencia
|
|
55
56
|
if (data.trim() && !result.code.trim()) {
|
|
56
|
-
|
|
57
|
+
logger.warn(`⚠️ Minificación fallida para ${filename}, usando código original`);
|
|
58
|
+
if (process.env.VERBOSE === 'true') {
|
|
59
|
+
logger.debug(`[Minify Debug] El resultado de oxc-minify fue un código vacío para un archivo de tamaño: ${data.length}`);
|
|
60
|
+
// Si el objeto result tiene otros campos útiles (como errores), los mostramos
|
|
61
|
+
if (Object.keys(result).length > 1) {
|
|
62
|
+
logger.debug(`[Minify Debug] Información adicional del resultado:`, JSON.stringify({ ...result, code: '[REDACTED]' }, null, 2));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
57
65
|
return {
|
|
58
66
|
code: data, // Retornar código original
|
|
59
67
|
error: null, // No es un error crítico
|
|
@@ -81,8 +89,15 @@ class MinificationCache {
|
|
|
81
89
|
}
|
|
82
90
|
catch (error) {
|
|
83
91
|
// En caso de excepción, retornar código original con advertencia
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
93
|
+
logger.warn(`⚠️ Error al minificar ${filename}: ${errorMsg}`);
|
|
94
|
+
logger.warn(` Usando código original sin minificar`);
|
|
95
|
+
if (process.env.VERBOSE === 'true') {
|
|
96
|
+
if (error instanceof Error && error.stack) {
|
|
97
|
+
logger.debug(`[Minify Debug] Stack trace: ${error.stack}`);
|
|
98
|
+
}
|
|
99
|
+
logger.debug(`[Minify Debug] Opciones de minificación:`, JSON.stringify(options, null, 2));
|
|
100
|
+
}
|
|
86
101
|
return {
|
|
87
102
|
code: data, // Retornar código original
|
|
88
103
|
error: null, // No propagar el error
|
|
@@ -102,7 +117,7 @@ class MinificationCache {
|
|
|
102
117
|
this.currentMemoryUsage += entrySize;
|
|
103
118
|
}
|
|
104
119
|
catch (error) {
|
|
105
|
-
|
|
120
|
+
logger.warn('[MinificationCache] Error cacheando minificación:', error);
|
|
106
121
|
}
|
|
107
122
|
}
|
|
108
123
|
/**
|
|
@@ -215,6 +230,10 @@ export const minifyJS = async (data, filename, isProd = true) => {
|
|
|
215
230
|
},
|
|
216
231
|
codegen: {
|
|
217
232
|
removeWhitespace: true,
|
|
233
|
+
normal: true,
|
|
234
|
+
jsdoc: true,
|
|
235
|
+
annotation: true,
|
|
236
|
+
legal: true
|
|
218
237
|
},
|
|
219
238
|
sourcemap: !isProd,
|
|
220
239
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { minifyHTMLLiterals } from 'minify-html-literals';
|
|
2
|
+
import { logger } from '../servicios/logger.js';
|
|
2
3
|
const defaultMinifyOptions = {
|
|
3
4
|
// Opciones esenciales para componentes Vue
|
|
4
5
|
caseSensitive: true, // Preserva mayúsculas/minúsculas en nombres de componentes
|
|
@@ -96,7 +97,7 @@ const detectAndTagTemplateStrings = (code) => {
|
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
catch (error) {
|
|
99
|
-
|
|
100
|
+
logger.warn('[MinifyTemplate] Error detectando template strings:', error);
|
|
100
101
|
return code;
|
|
101
102
|
}
|
|
102
103
|
};
|
|
@@ -113,7 +114,7 @@ const removeTemporaryTags = (code) => {
|
|
|
113
114
|
return code.replace(tempHtmlPattern, '`').replace(tempCssPattern, '`');
|
|
114
115
|
}
|
|
115
116
|
catch (error) {
|
|
116
|
-
|
|
117
|
+
logger.warn('[MinifyTemplate] Error removiendo tags temporales:', error);
|
|
117
118
|
return code;
|
|
118
119
|
}
|
|
119
120
|
};
|
|
@@ -163,7 +164,7 @@ const minifyCSS = (code) => {
|
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
166
|
catch (error) {
|
|
166
|
-
|
|
167
|
+
logger.warn('[MinifyTemplate] Error minificando CSS:', error);
|
|
167
168
|
return code;
|
|
168
169
|
}
|
|
169
170
|
};
|
|
@@ -208,7 +209,7 @@ const minifyTemplate = (data, fileName) => {
|
|
|
208
209
|
catch (parseError) {
|
|
209
210
|
// Si minifyHTMLLiterals falla (ej: encuentra código TypeScript en vez de HTML),
|
|
210
211
|
// devolver el código sin minificar en lugar de fallar completamente
|
|
211
|
-
|
|
212
|
+
logger.warn(`[MinifyTemplate] minifyHTMLLiterals falló para ${fileName}, usando código sin minificar:`, parseError instanceof Error
|
|
212
213
|
? parseError.message
|
|
213
214
|
: String(parseError));
|
|
214
215
|
// minifiedCode ya tiene el valor de code
|
|
@@ -221,7 +222,7 @@ const minifyTemplate = (data, fileName) => {
|
|
|
221
222
|
return { code: finalCode, error: null };
|
|
222
223
|
}
|
|
223
224
|
catch (error) {
|
|
224
|
-
|
|
225
|
+
logger.warn(`[MinifyTemplate] Error minificando plantilla ${fileName}:`, error);
|
|
225
226
|
return { code: data, error };
|
|
226
227
|
}
|
|
227
228
|
};
|
|
@@ -539,7 +539,7 @@ export async function estandarizaCode(code, file) {
|
|
|
539
539
|
code = await replaceAliasInStrings(code);
|
|
540
540
|
code = await removehtmlOfTemplateString(code);
|
|
541
541
|
code = await removeCodeTagImport(code);
|
|
542
|
-
if (env.
|
|
542
|
+
if (env.isPROD === 'true') {
|
|
543
543
|
code = await removePreserverComent(code);
|
|
544
544
|
}
|
|
545
545
|
return { code, error: null };
|
|
@@ -241,6 +241,7 @@ export const preCompileTS = async (data, fileName) => {
|
|
|
241
241
|
// Modo más rápido
|
|
242
242
|
incremental: false, // No usar incremental en transpileModule
|
|
243
243
|
diagnostics: false,
|
|
244
|
+
removeComments: env.isPROD === 'true',
|
|
244
245
|
},
|
|
245
246
|
fileName,
|
|
246
247
|
reportDiagnostics: env.VERBOSE === 'true', // Solo reportar en verbose
|
package/dist/compiler/vuejs.js
CHANGED
|
@@ -47,8 +47,10 @@ class VueHMRInjectionCache {
|
|
|
47
47
|
// Generar nueva inyección HMR
|
|
48
48
|
const vueImportPattern = /import\s*\{[^}]*\bref\b[^}]*\}\s*from\s*['"]vue['"]/;
|
|
49
49
|
const hasRefImport = vueImportPattern.test(originalData);
|
|
50
|
+
// ✨ FIX: Construir el import dinámicamente para evitar que el compilador lo transforme
|
|
51
|
+
const vueRefImport = ['import', '{ ref }', 'from', '"vue"'].join(' ') + ';';
|
|
50
52
|
const varContent = `
|
|
51
|
-
${hasRefImport ? '' :
|
|
53
|
+
${hasRefImport ? '' : vueRefImport}
|
|
52
54
|
const versaComponentKey = ref(0);
|
|
53
55
|
`;
|
|
54
56
|
let injectedData;
|
|
@@ -248,8 +250,8 @@ export const preCompileVue = async (data, source, isProd = false) => {
|
|
|
248
250
|
prefixIdentifiers: true,
|
|
249
251
|
hoistStatic: isProd,
|
|
250
252
|
cacheHandlers: isProd,
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
runtimeGlobalName: 'Vue',
|
|
254
|
+
runtimeModuleName: 'vue',
|
|
253
255
|
whitespace: 'condense',
|
|
254
256
|
ssr: false,
|
|
255
257
|
comments: !isProd, // ✨ Eliminar comentarios HTML del template
|
package/dist/main.js
CHANGED
|
@@ -97,6 +97,7 @@ async function main() {
|
|
|
97
97
|
default: false, // Por defecto, verbose está deshabilitado
|
|
98
98
|
})
|
|
99
99
|
.alias('v', 'verbose')
|
|
100
|
+
.alias('debug', 'verbose')
|
|
100
101
|
.option('cleanOutput', {
|
|
101
102
|
type: 'boolean',
|
|
102
103
|
description: 'Limpiar el directorio de salida antes de compilar',
|
package/package.json
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "versacompiler",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"description": "Una herramienta para compilar y minificar archivos .vue, .js y .ts para proyectos de Vue 3 con soporte para TypeScript.",
|
|
5
|
-
"main": "dist/main.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"versacompiler": "dist/main.js"
|
|
8
|
-
},
|
|
9
|
-
"publishConfig": {
|
|
10
|
-
"access": "public"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"LICENSE",
|
|
15
|
-
"README.md"
|
|
16
|
-
],
|
|
17
|
-
"type": "module",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"dev": "tsx --watch src/main.ts --watch --verbose --tailwind",
|
|
20
|
-
"file": "tsx src/main.ts ",
|
|
21
|
-
"compile": "tsx src/main.ts --all --cc -y --verbose --prod",
|
|
22
|
-
"compileDev": "tsx src/main.ts --all --cc -y --verbose",
|
|
23
|
-
"test": "vitest run",
|
|
24
|
-
"test:watch": "vitest",
|
|
25
|
-
"test:ui": "vitest --ui",
|
|
26
|
-
"test:coverage": "vitest run --coverage",
|
|
27
|
-
"build": "tsx src/main.ts --all -t --cc --co -y --verbose",
|
|
28
|
-
"lint": "oxlint --fix --config .oxlintrc.json",
|
|
29
|
-
"lint:eslint": "eslint --ext .js,.ts,.vue src/ --fix"
|
|
30
|
-
},
|
|
31
|
-
"keywords": [
|
|
32
|
-
"vue",
|
|
33
|
-
"compiler",
|
|
34
|
-
"minifier",
|
|
35
|
-
"vue3",
|
|
36
|
-
"versacompiler",
|
|
37
|
-
"typescript",
|
|
38
|
-
"linter"
|
|
39
|
-
],
|
|
40
|
-
"author": "Jorge Jara H (kriollone@gmail.com)",
|
|
41
|
-
"license": "MIT",
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/kriollo/versaCompiler.git"
|
|
45
|
-
},
|
|
46
|
-
"bugs": {
|
|
47
|
-
"url": "https://github.com/kriollo/versaCompiler/issues"
|
|
48
|
-
},
|
|
49
|
-
"homepage": "https://github.com/kriollo/versaCompiler#readme",
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"@vue/compiler-dom": "^3.5.
|
|
52
|
-
"@vue/reactivity": "^3.5.
|
|
53
|
-
"@vue/runtime-core": "^3.5.
|
|
54
|
-
"@vue/runtime-dom": "^3.5.
|
|
55
|
-
"browser-sync": "^3.0.4",
|
|
56
|
-
"chalk": "5.6.2",
|
|
57
|
-
"chokidar": "^5.0.0",
|
|
58
|
-
"enhanced-resolve": "^5.
|
|
59
|
-
"execa": "^9.6.
|
|
60
|
-
"find-root": "^1.1.0",
|
|
61
|
-
"fs-extra": "^11.3.
|
|
62
|
-
"get-port": "^7.1.0",
|
|
63
|
-
"minify-html-literals": "^1.3.5",
|
|
64
|
-
"minimatch": "^10.1.
|
|
65
|
-
"oxc-minify": "^0.
|
|
66
|
-
"oxc-parser": "^0.
|
|
67
|
-
"oxc-transform": "^0.
|
|
68
|
-
"resolve": "^1.22.11",
|
|
69
|
-
"tsx": "^4.
|
|
70
|
-
"typescript": "^5.9.3",
|
|
71
|
-
"vue": "3.5.
|
|
72
|
-
"yargs": "^18.0.0"
|
|
73
|
-
},
|
|
74
|
-
"devDependencies": {
|
|
75
|
-
"@eslint/eslintrc": "^3.3.
|
|
76
|
-
"@tailwindcss/cli": "^4.1.
|
|
77
|
-
"@types/browser-sync": "^2.29.1",
|
|
78
|
-
"@types/find-root": "^1.1.4",
|
|
79
|
-
"@types/fs-extra": "^11.0.4",
|
|
80
|
-
"@types/jest": "^30.0.0",
|
|
81
|
-
"@types/mocha": "^10.0.10",
|
|
82
|
-
"@types/node": "^25.0
|
|
83
|
-
"@types/resolve": "^1.20.6",
|
|
84
|
-
"@types/yargs": "^17.0.35",
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
86
|
-
"@typescript-eslint/parser": "^8.
|
|
87
|
-
"@vitest/coverage-v8": "^4.0.
|
|
88
|
-
"@vitest/ui": "^4.0.
|
|
89
|
-
"@vue/eslint-config-typescript": "^14.6.0",
|
|
90
|
-
"@vue/test-utils": "^2.4.6",
|
|
91
|
-
"code-tag": "^1.2.0",
|
|
92
|
-
"eslint": "^9.39.
|
|
93
|
-
"eslint-import-resolver-typescript": "^4.4.4",
|
|
94
|
-
"eslint-plugin-import": "^2.32.0",
|
|
95
|
-
"eslint-plugin-oxlint": "^1.
|
|
96
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
97
|
-
"eslint-plugin-unicorn": "^62.0.0",
|
|
98
|
-
"eslint-plugin-vue": "^10.
|
|
99
|
-
"oxlint": "^1.
|
|
100
|
-
"pinia": "^3.0.4",
|
|
101
|
-
"prettier": "3.8.
|
|
102
|
-
"rimraf": "^6.1.
|
|
103
|
-
"sweetalert2": "^11.26.
|
|
104
|
-
"tailwindcss": "^4.1.
|
|
105
|
-
"vitest": "^4.0.
|
|
106
|
-
"vue-eslint-parser": "^10.2.0",
|
|
107
|
-
"vue-router": "^
|
|
108
|
-
},
|
|
109
|
-
"packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b"
|
|
110
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "versacompiler",
|
|
3
|
+
"version": "2.3.3",
|
|
4
|
+
"description": "Una herramienta para compilar y minificar archivos .vue, .js y .ts para proyectos de Vue 3 con soporte para TypeScript.",
|
|
5
|
+
"main": "dist/main.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"versacompiler": "dist/main.js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "tsx --watch src/main.ts --watch --verbose --tailwind",
|
|
20
|
+
"file": "tsx src/main.ts ",
|
|
21
|
+
"compile": "tsx src/main.ts --all --cc --co -y --verbose --prod",
|
|
22
|
+
"compileDev": "tsx src/main.ts --all --cc -y --verbose",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"test:ui": "vitest --ui",
|
|
26
|
+
"test:coverage": "vitest run --coverage",
|
|
27
|
+
"build": "tsx src/main.ts --all -t --cc --co -y --verbose",
|
|
28
|
+
"lint": "oxlint --fix --config .oxlintrc.json",
|
|
29
|
+
"lint:eslint": "eslint --ext .js,.ts,.vue src/ --fix"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"vue",
|
|
33
|
+
"compiler",
|
|
34
|
+
"minifier",
|
|
35
|
+
"vue3",
|
|
36
|
+
"versacompiler",
|
|
37
|
+
"typescript",
|
|
38
|
+
"linter"
|
|
39
|
+
],
|
|
40
|
+
"author": "Jorge Jara H (kriollone@gmail.com)",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/kriollo/versaCompiler.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/kriollo/versaCompiler/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/kriollo/versaCompiler#readme",
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@vue/compiler-dom": "^3.5.27",
|
|
52
|
+
"@vue/reactivity": "^3.5.27",
|
|
53
|
+
"@vue/runtime-core": "^3.5.27",
|
|
54
|
+
"@vue/runtime-dom": "^3.5.27",
|
|
55
|
+
"browser-sync": "^3.0.4",
|
|
56
|
+
"chalk": "5.6.2",
|
|
57
|
+
"chokidar": "^5.0.0",
|
|
58
|
+
"enhanced-resolve": "^5.19.0",
|
|
59
|
+
"execa": "^9.6.1",
|
|
60
|
+
"find-root": "^1.1.0",
|
|
61
|
+
"fs-extra": "^11.3.3",
|
|
62
|
+
"get-port": "^7.1.0",
|
|
63
|
+
"minify-html-literals": "^1.3.5",
|
|
64
|
+
"minimatch": "^10.1.2",
|
|
65
|
+
"oxc-minify": "^0.112.0",
|
|
66
|
+
"oxc-parser": "^0.112.0",
|
|
67
|
+
"oxc-transform": "^0.112.0",
|
|
68
|
+
"resolve": "^1.22.11",
|
|
69
|
+
"tsx": "^4.21.0",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"vue": "3.5.27",
|
|
72
|
+
"yargs": "^18.0.0"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
76
|
+
"@tailwindcss/cli": "^4.1.18",
|
|
77
|
+
"@types/browser-sync": "^2.29.1",
|
|
78
|
+
"@types/find-root": "^1.1.4",
|
|
79
|
+
"@types/fs-extra": "^11.0.4",
|
|
80
|
+
"@types/jest": "^30.0.0",
|
|
81
|
+
"@types/mocha": "^10.0.10",
|
|
82
|
+
"@types/node": "^25.2.0",
|
|
83
|
+
"@types/resolve": "^1.20.6",
|
|
84
|
+
"@types/yargs": "^17.0.35",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
86
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
87
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
88
|
+
"@vitest/ui": "^4.0.18",
|
|
89
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
90
|
+
"@vue/test-utils": "^2.4.6",
|
|
91
|
+
"code-tag": "^1.2.0",
|
|
92
|
+
"eslint": "^9.39.2",
|
|
93
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
94
|
+
"eslint-plugin-import": "^2.32.0",
|
|
95
|
+
"eslint-plugin-oxlint": "^1.43.0",
|
|
96
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
97
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
98
|
+
"eslint-plugin-vue": "^10.7.0",
|
|
99
|
+
"oxlint": "^1.43.0",
|
|
100
|
+
"pinia": "^3.0.4",
|
|
101
|
+
"prettier": "3.8.1",
|
|
102
|
+
"rimraf": "^6.1.2",
|
|
103
|
+
"sweetalert2": "^11.26.18",
|
|
104
|
+
"tailwindcss": "^4.1.18",
|
|
105
|
+
"vitest": "^4.0.18",
|
|
106
|
+
"vue-eslint-parser": "^10.2.0",
|
|
107
|
+
"vue-router": "^5.0.2"
|
|
108
|
+
},
|
|
109
|
+
"packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b"
|
|
110
|
+
}
|