versacompiler 2.4.1 → 2.6.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.
Files changed (52) hide show
  1. package/README.md +722 -722
  2. package/dist/compiler/compile-worker-pool.js +108 -0
  3. package/dist/compiler/compile-worker-thread.cjs +72 -0
  4. package/dist/compiler/compile.js +177 -18
  5. package/dist/compiler/error-reporter.js +12 -0
  6. package/dist/compiler/integrity-validator.js +13 -1
  7. package/dist/compiler/linter.js +12 -0
  8. package/dist/compiler/minify.js +12 -0
  9. package/dist/compiler/minifyTemplate.js +12 -0
  10. package/dist/compiler/module-resolution-optimizer.js +35 -20
  11. package/dist/compiler/parser.js +12 -0
  12. package/dist/compiler/performance-monitor.js +73 -61
  13. package/dist/compiler/pipeline/build-pipeline.js +139 -0
  14. package/dist/compiler/pipeline/core-plugins.js +230 -0
  15. package/dist/compiler/pipeline/module-graph.js +75 -0
  16. package/dist/compiler/pipeline/plugin-driver.js +99 -0
  17. package/dist/compiler/pipeline/types.js +14 -0
  18. package/dist/compiler/tailwindcss.js +12 -0
  19. package/dist/compiler/transform-optimizer.js +12 -0
  20. package/dist/compiler/transformTStoJS.js +38 -5
  21. package/dist/compiler/transforms.js +234 -16
  22. package/dist/compiler/typescript-compiler.js +12 -0
  23. package/dist/compiler/typescript-error-parser.js +12 -0
  24. package/dist/compiler/typescript-manager.js +15 -1
  25. package/dist/compiler/typescript-sync-validator.js +45 -31
  26. package/dist/compiler/typescript-worker-pool.js +12 -0
  27. package/dist/compiler/typescript-worker-thread.cjs +482 -475
  28. package/dist/compiler/typescript-worker.js +12 -0
  29. package/dist/compiler/vuejs.js +73 -47
  30. package/dist/config.js +14 -0
  31. package/dist/hrm/VueHRM.js +484 -359
  32. package/dist/hrm/errorScreen.js +95 -83
  33. package/dist/hrm/getInstanciaVue.js +325 -313
  34. package/dist/hrm/initHRM.js +736 -586
  35. package/dist/hrm/versaHMR.js +317 -0
  36. package/dist/main.js +23 -3
  37. package/dist/servicios/browserSync.js +127 -6
  38. package/dist/servicios/file-watcher.js +139 -8
  39. package/dist/servicios/logger.js +12 -0
  40. package/dist/servicios/readConfig.js +141 -54
  41. package/dist/servicios/versacompile.config.types.js +14 -0
  42. package/dist/utils/excluded-modules.js +12 -0
  43. package/dist/utils/module-resolver.js +86 -40
  44. package/dist/utils/promptUser.js +12 -0
  45. package/dist/utils/proxyValidator.js +12 -0
  46. package/dist/utils/resolve-bin.js +12 -0
  47. package/dist/utils/utils.js +12 -0
  48. package/dist/utils/vue-types-setup.js +260 -248
  49. package/dist/wrappers/eslint-node.js +15 -1
  50. package/dist/wrappers/oxlint-node.js +15 -1
  51. package/dist/wrappers/tailwind-node.js +12 -0
  52. package/package.json +74 -54
@@ -0,0 +1,75 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
13
+ export class ModuleGraph {
14
+ nodes = new Map();
15
+ getNode(id) {
16
+ return this.nodes.get(id);
17
+ }
18
+ ensureNode(id) {
19
+ const existing = this.nodes.get(id);
20
+ if (existing)
21
+ return existing;
22
+ const node = {
23
+ id,
24
+ importers: new Set(),
25
+ imports: new Set(),
26
+ lastUpdated: Date.now(),
27
+ };
28
+ this.nodes.set(id, node);
29
+ return node;
30
+ }
31
+ updateImports(id, imports) {
32
+ const node = this.ensureNode(id);
33
+ node.imports.clear();
34
+ for (const dep of imports) {
35
+ node.imports.add(dep);
36
+ const depNode = this.ensureNode(dep);
37
+ depNode.importers.add(id);
38
+ }
39
+ node.lastUpdated = Date.now();
40
+ }
41
+ invalidate(id) {
42
+ const invalidated = new Set();
43
+ const queue = [id];
44
+ while (queue.length > 0) {
45
+ const current = queue.shift();
46
+ if (invalidated.has(current))
47
+ continue;
48
+ invalidated.add(current);
49
+ const node = this.nodes.get(current);
50
+ if (!node)
51
+ continue;
52
+ for (const importer of node.importers) {
53
+ queue.push(importer);
54
+ }
55
+ }
56
+ return Array.from(invalidated);
57
+ }
58
+ remove(id) {
59
+ const node = this.nodes.get(id);
60
+ if (!node)
61
+ return;
62
+ for (const dep of node.imports) {
63
+ const depNode = this.nodes.get(dep);
64
+ if (depNode)
65
+ depNode.importers.delete(id);
66
+ }
67
+ for (const importer of node.importers) {
68
+ const importerNode = this.nodes.get(importer);
69
+ if (importerNode)
70
+ importerNode.imports.delete(id);
71
+ }
72
+ this.nodes.delete(id);
73
+ }
74
+ }
75
+ //# sourceMappingURL=module-graph.js.map
@@ -0,0 +1,99 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
13
+ export class PluginDriver {
14
+ plugins;
15
+ constructor(plugins) {
16
+ this.plugins = plugins;
17
+ }
18
+ async resolve(args) {
19
+ for (const plugin of this.plugins) {
20
+ if (!plugin.onResolve)
21
+ continue;
22
+ const result = await plugin.onResolve(args);
23
+ if (result && (result.path || result.external || result.errors)) {
24
+ return result;
25
+ }
26
+ }
27
+ return {};
28
+ }
29
+ async load(args) {
30
+ for (const plugin of this.plugins) {
31
+ if (!plugin.onLoad)
32
+ continue;
33
+ const result = await plugin.onLoad(args);
34
+ if (result && (result.contents || result.errors)) {
35
+ return result;
36
+ }
37
+ }
38
+ return {};
39
+ }
40
+ async transform(args) {
41
+ let current = args.contents;
42
+ let currentLoader = args.loader;
43
+ let currentMeta = args.meta;
44
+ let errors = [];
45
+ for (const plugin of this.plugins) {
46
+ if (!plugin.onTransform)
47
+ continue;
48
+ const result = await plugin.onTransform({
49
+ ...args,
50
+ contents: current,
51
+ loader: currentLoader,
52
+ meta: currentMeta,
53
+ });
54
+ if (result.errors?.length)
55
+ errors = errors.concat(result.errors);
56
+ if (result.contents)
57
+ current = result.contents;
58
+ if (result.loader)
59
+ currentLoader = result.loader;
60
+ if (result.meta)
61
+ currentMeta = {
62
+ ...(currentMeta || {}),
63
+ ...result.meta,
64
+ };
65
+ }
66
+ return {
67
+ contents: current,
68
+ loader: currentLoader,
69
+ meta: currentMeta,
70
+ errors: errors.length ? errors : undefined,
71
+ };
72
+ }
73
+ async hotUpdate(args) {
74
+ let reload = 'none';
75
+ let errors = [];
76
+ for (const plugin of this.plugins) {
77
+ if (!plugin.onHotUpdate)
78
+ continue;
79
+ const result = await plugin.onHotUpdate(args);
80
+ if (result.errors?.length)
81
+ errors = errors.concat(result.errors);
82
+ if (result.reload === 'full')
83
+ reload = 'full';
84
+ if (result.reload === 'module' && reload !== 'full')
85
+ reload = 'module';
86
+ }
87
+ return { reload, errors: errors.length ? errors : undefined };
88
+ }
89
+ async end(errors) {
90
+ const args = { errors };
91
+ for (const plugin of this.plugins) {
92
+ if (!plugin.onEnd)
93
+ continue;
94
+ await plugin.onEnd(args);
95
+ }
96
+ return { errors };
97
+ }
98
+ }
99
+ //# sourceMappingURL=plugin-driver.js.map
@@ -0,0 +1,14 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
13
+ export {};
14
+ //# sourceMappingURL=types.js.map
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { env } from 'node:process';
2
14
  import { logger } from '../servicios/logger.js';
3
15
  import { TailwindNode } from '../wrappers/tailwind-node.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * Transform Optimizer - Sistema de optimización de transformaciones AST
3
15
  * Implementa procesamiento paralelo y caching inteligente para transformaciones
@@ -1,16 +1,49 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { transform } from '/node_modules/oxc-transform/browser.js';
2
- export async function traspileTStoJS(filePath, sourceCode) {
14
+ export async function transpileTStoJS(filePath, sourceCode) {
3
15
  try {
4
16
  const { code: outputText, declaration, errors: diagnostics, } = await transform(filePath, sourceCode);
17
+ // Si oxc-transform devuelve código vacío ante una entrada no vacía,
18
+ // usar el fuente original como fallback para no corromper el pipeline.
19
+ if (!outputText && sourceCode.trim()) {
20
+ return {
21
+ outputText: sourceCode,
22
+ declaration: declaration || '',
23
+ diagnostics: [
24
+ `Warning: oxc-transform produjo salida vacía para ${filePath}, usando fuente original`,
25
+ ...(diagnostics ?? []).map(d => typeof d === 'string' ? d : JSON.stringify(d)),
26
+ ],
27
+ };
28
+ }
5
29
  return {
6
- outputText: outputText,
30
+ outputText: outputText ?? sourceCode,
7
31
  declaration: declaration || '',
8
- diagnostics: diagnostics || [],
32
+ diagnostics: (diagnostics ?? []).map(d => typeof d === 'string' ? d : JSON.stringify(d)),
9
33
  };
10
34
  }
11
35
  catch (error) {
12
- console.error(`Error transpiling ${filePath}:`, error);
13
- return { outputText: '', declaration: '', diagnostics: [error] };
36
+ const errorMsg = error instanceof Error ? error.message : String(error);
37
+ // Fallback al fuente original para que el pipeline no reciba código vacío
38
+ return {
39
+ outputText: sourceCode,
40
+ declaration: '',
41
+ diagnostics: [
42
+ `Error durante transpilación de ${filePath}: ${errorMsg}. Usando fuente original.`,
43
+ ],
44
+ };
14
45
  }
15
46
  }
47
+ /** @deprecated Usar transpileTStoJS (corrección de typo histórico) */
48
+ export const traspileTStoJS = transpileTStoJS;
16
49
  //# sourceMappingURL=transformTStoJS.js.map
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import path from 'node:path';
2
14
  import { env } from 'node:process';
3
15
  import { logger } from '../servicios/logger.js';
@@ -90,7 +102,9 @@ function isExternalModule(moduleRequest, pathAlias) {
90
102
  return true;
91
103
  } // Descartar alias conocidos
92
104
  for (const alias of Object.keys(pathAlias)) {
93
- const aliasPattern = alias.replace('/*', '');
105
+ // Quitar solo el '*' final para conservar el separador '/'
106
+ // Ejemplo: '@/*' → '@/', así '@vueuse/core' no hace match pero '@/foo' sí
107
+ const aliasPattern = alias.replace('*', '');
94
108
  if (moduleRequest.startsWith(aliasPattern)) {
95
109
  return false;
96
110
  }
@@ -105,6 +119,211 @@ function isExternalModule(moduleRequest, pathAlias) {
105
119
  // Si llegamos aquí, es probablemente un módulo externo
106
120
  return true;
107
121
  }
122
+ async function resolveModuleRequest(moduleRequest, file, pathAlias) {
123
+ let newPath = null;
124
+ let transformed = false;
125
+ if (!transformed && isExternalModule(moduleRequest, pathAlias)) {
126
+ try {
127
+ const optimizedResult = await getOptimizedModulePath(moduleRequest, file);
128
+ if (optimizedResult.excluded) {
129
+ return null;
130
+ }
131
+ if (optimizedResult.path) {
132
+ newPath = optimizedResult.path;
133
+ transformed = true;
134
+ }
135
+ else {
136
+ const modulePath = getModuleSubPath(moduleRequest, file);
137
+ if (modulePath === null) {
138
+ return null;
139
+ }
140
+ if (modulePath) {
141
+ newPath = modulePath;
142
+ transformed = true;
143
+ }
144
+ }
145
+ }
146
+ catch (error) {
147
+ if (env.VERBOSE === 'true')
148
+ logger.warn(`Error resolviendo módulo ${moduleRequest}: ${error instanceof Error ? error.message : String(error)}`);
149
+ }
150
+ }
151
+ if (!transformed) {
152
+ const aliasPath = getOptimizedAliasPath(moduleRequest);
153
+ if (aliasPath) {
154
+ let newImportPath = aliasPath;
155
+ if (newImportPath.endsWith('.ts') ||
156
+ newImportPath.endsWith('.vue')) {
157
+ newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
158
+ }
159
+ else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
160
+ newImportPath += '.js';
161
+ }
162
+ newPath = newImportPath;
163
+ transformed = true;
164
+ }
165
+ else {
166
+ for (const [alias] of Object.entries(pathAlias)) {
167
+ const aliasPattern = alias.replace('*', '');
168
+ if (moduleRequest.startsWith(aliasPattern)) {
169
+ const relativePath = moduleRequest.replace(aliasPattern, '');
170
+ let newImportPath = path.join('/', env.PATH_DIST, relativePath);
171
+ newImportPath = newImportPath
172
+ .replace(/\/\.\//g, '/')
173
+ .replace(/\\/g, '/');
174
+ if (newImportPath.endsWith('.ts') ||
175
+ newImportPath.endsWith('.vue')) {
176
+ newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
177
+ }
178
+ else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
179
+ newImportPath += '.js';
180
+ }
181
+ newPath = newImportPath;
182
+ transformed = true;
183
+ break;
184
+ }
185
+ }
186
+ }
187
+ }
188
+ if (!transformed &&
189
+ (moduleRequest.startsWith('./') || moduleRequest.startsWith('../'))) {
190
+ let relativePath = moduleRequest;
191
+ if (relativePath.endsWith('.ts') || relativePath.endsWith('.vue')) {
192
+ relativePath = relativePath.replace(/\.(ts|vue)$/, '.js');
193
+ newPath = relativePath;
194
+ transformed = true;
195
+ }
196
+ else if (!/\.(js|mjs|css|json)$/.test(relativePath)) {
197
+ newPath = relativePath + '.js';
198
+ transformed = true;
199
+ }
200
+ }
201
+ return transformed ? newPath : null;
202
+ }
203
+ function extractLiteralValue(raw) {
204
+ if (!raw || raw.length < 2)
205
+ return null;
206
+ const quote = raw[0];
207
+ const last = raw[raw.length - 1];
208
+ if ((quote !== '"' && quote !== "'" && quote !== '`') || last !== quote) {
209
+ return null;
210
+ }
211
+ if (quote === '`' && raw.includes('${')) {
212
+ return null;
213
+ }
214
+ return { quote, value: raw.slice(1, -1) };
215
+ }
216
+ function resolveAliasTemplateLiteral(raw, pathAlias) {
217
+ if (!raw.startsWith('`'))
218
+ return null;
219
+ const exprIndex = raw.indexOf('${');
220
+ if (exprIndex === -1)
221
+ return null;
222
+ const prefix = raw.slice(1, exprIndex);
223
+ if (!prefix)
224
+ return null;
225
+ const sortedAliases = Object.entries(pathAlias).sort((a, b) => {
226
+ const aliasA = a[0].replace('/*', '');
227
+ const aliasB = b[0].replace('/*', '');
228
+ return aliasB.length - aliasA.length;
229
+ });
230
+ for (const [alias, target] of sortedAliases) {
231
+ const aliasPattern = alias.replace('/*', '');
232
+ if (!prefix.startsWith(aliasPattern))
233
+ continue;
234
+ const relativePath = prefix.replace(aliasPattern, '');
235
+ const targetArray = Array.isArray(target) ? target : [target];
236
+ const targetPath = targetArray[0];
237
+ if (!targetPath)
238
+ continue;
239
+ let newPrefix;
240
+ if (targetPath.startsWith('/')) {
241
+ newPrefix = path.join('/', env.PATH_DIST, relativePath);
242
+ }
243
+ else {
244
+ const cleanTarget = targetPath.replace('./', '').replace('/*', '');
245
+ const normalizedPathDist = env.PATH_DIST.replace('./', '');
246
+ if (cleanTarget === normalizedPathDist) {
247
+ newPrefix = path.join('/', normalizedPathDist, relativePath);
248
+ }
249
+ else {
250
+ newPrefix = path.join('/', normalizedPathDist, cleanTarget, relativePath);
251
+ }
252
+ }
253
+ newPrefix = newPrefix
254
+ .replace(/\/\.\//g, '/')
255
+ .replace(/\\/g, '/')
256
+ .replace(/\/+/g, '/');
257
+ return `\`${newPrefix}${raw.slice(exprIndex)}`;
258
+ }
259
+ return null;
260
+ }
261
+ async function replaceAliasImportsAst(code, file, ast) {
262
+ if (!env.PATH_ALIAS || !env.PATH_DIST) {
263
+ return code;
264
+ }
265
+ const pathAlias = getParsedPathAlias();
266
+ if (!pathAlias)
267
+ return code;
268
+ const replacements = [];
269
+ const staticImports = ast?.module?.staticImports || [];
270
+ for (const item of staticImports) {
271
+ const moduleRequest = item?.moduleRequest?.value;
272
+ const start = item?.moduleRequest?.start;
273
+ const end = item?.moduleRequest?.end;
274
+ if (typeof moduleRequest !== 'string')
275
+ continue;
276
+ if (typeof start !== 'number' || typeof end !== 'number')
277
+ continue;
278
+ const newPath = await resolveModuleRequest(moduleRequest, file, pathAlias);
279
+ if (!newPath || newPath === moduleRequest)
280
+ continue;
281
+ const raw = code.slice(start, end);
282
+ const literal = extractLiteralValue(raw);
283
+ if (!literal)
284
+ continue;
285
+ replacements.push({
286
+ start,
287
+ end,
288
+ value: `${literal.quote}${newPath}${literal.quote}`,
289
+ });
290
+ }
291
+ const dynamicImports = ast?.module?.dynamicImports || [];
292
+ for (const item of dynamicImports) {
293
+ const start = item?.moduleRequest?.start;
294
+ const end = item?.moduleRequest?.end;
295
+ if (typeof start !== 'number' || typeof end !== 'number')
296
+ continue;
297
+ const raw = code.slice(start, end);
298
+ const literal = extractLiteralValue(raw);
299
+ if (!literal) {
300
+ const replaced = resolveAliasTemplateLiteral(raw, pathAlias);
301
+ if (replaced) {
302
+ replacements.push({ start, end, value: replaced });
303
+ }
304
+ continue;
305
+ }
306
+ const newPath = await resolveModuleRequest(literal.value, file, pathAlias);
307
+ if (!newPath || newPath === literal.value)
308
+ continue;
309
+ replacements.push({
310
+ start,
311
+ end,
312
+ value: `${literal.quote}${newPath}${literal.quote}`,
313
+ });
314
+ }
315
+ if (replacements.length === 0)
316
+ return code;
317
+ replacements.sort((a, b) => b.start - a.start);
318
+ let resultCode = code;
319
+ for (const replacement of replacements) {
320
+ resultCode =
321
+ resultCode.slice(0, replacement.start) +
322
+ replacement.value +
323
+ resultCode.slice(replacement.end);
324
+ }
325
+ return resultCode;
326
+ }
108
327
  export async function replaceAliasImportStatic(file, code) {
109
328
  if (!env.PATH_ALIAS || !env.PATH_DIST) {
110
329
  return code;
@@ -124,13 +343,13 @@ export async function replaceAliasImportStatic(file, code) {
124
343
  if (!transformed && isExternalModule(moduleRequest, pathAlias)) {
125
344
  try {
126
345
  // Usar el sistema optimizado primero
127
- const optimizedPath = await getOptimizedModulePath(moduleRequest, file);
128
- if (optimizedPath === null) {
129
- // Si el optimizador retorna null, significa que es un módulo excluido
346
+ const optimizedResult = await getOptimizedModulePath(moduleRequest, file);
347
+ if (optimizedResult.excluded) {
348
+ // Módulo excluido explícitamente: mantener importación original
130
349
  continue;
131
350
  }
132
- if (optimizedPath) {
133
- newPath = optimizedPath;
351
+ if (optimizedResult.path) {
352
+ newPath = optimizedResult.path;
134
353
  transformed = true;
135
354
  }
136
355
  else {
@@ -169,7 +388,7 @@ export async function replaceAliasImportStatic(file, code) {
169
388
  else {
170
389
  // Fallback al sistema anterior
171
390
  for (const [alias] of Object.entries(pathAlias)) {
172
- const aliasPattern = alias.replace('/*', '');
391
+ const aliasPattern = alias.replace('*', '');
173
392
  if (moduleRequest.startsWith(aliasPattern)) {
174
393
  // Reemplazar el alias con la ruta del target
175
394
  const relativePath = moduleRequest.replace(aliasPattern, '');
@@ -239,13 +458,13 @@ export async function replaceAliasImportDynamic(code, _imports, file) {
239
458
  if (!transformed && isExternalModule(moduleRequest, pathAlias)) {
240
459
  try {
241
460
  // Usar el sistema optimizado primero
242
- const optimizedPath = await getOptimizedModulePath(moduleRequest, file);
243
- if (optimizedPath === null) {
244
- // Si el optimizador retorna null, significa que es un módulo excluido
461
+ const optimizedResult = await getOptimizedModulePath(moduleRequest, file);
462
+ if (optimizedResult.excluded) {
463
+ // Módulo excluido explícitamente: mantener importación original
245
464
  continue;
246
465
  }
247
- if (optimizedPath) {
248
- newPath = optimizedPath;
466
+ if (optimizedResult.path) {
467
+ newPath = optimizedResult.path;
249
468
  transformed = true;
250
469
  }
251
470
  else {
@@ -284,7 +503,7 @@ export async function replaceAliasImportDynamic(code, _imports, file) {
284
503
  else {
285
504
  // Fallback al sistema anterior
286
505
  for (const [alias] of Object.entries(pathAlias)) {
287
- const aliasPattern = alias.replace('/*', '');
506
+ const aliasPattern = alias.replace('*', '');
288
507
  if (moduleRequest.startsWith(aliasPattern)) {
289
508
  // Reemplazar el alias con la ruta del target
290
509
  const relativePath = moduleRequest.replace(aliasPattern, '');
@@ -356,7 +575,7 @@ export async function replaceAliasImportDynamic(code, _imports, file) {
356
575
  // 2. Verificar aliases en template literals
357
576
  if (!transformed) {
358
577
  for (const [alias] of Object.entries(pathAlias)) {
359
- const aliasPattern = alias.replace('/*', '');
578
+ const aliasPattern = alias.replace('*', '');
360
579
  if (moduleRequest.includes(aliasPattern)) {
361
580
  const relativePath = moduleRequest.replace(aliasPattern, '');
362
581
  // Para alias que apuntan a la raíz (como @/* -> /src/*),
@@ -550,8 +769,7 @@ export async function estandarizaCode(code, file) {
550
769
  const firstError = ast.errors[0];
551
770
  throw new Error(firstError?.message || 'Error sin mensaje');
552
771
  }
553
- code = await replaceAliasImportStatic(file, code);
554
- code = await replaceAliasImportDynamic(code, ast?.module.dynamicImports, file);
772
+ code = await replaceAliasImportsAst(code, file, ast);
555
773
  code = await replaceAliasInStrings(code);
556
774
  code = await removehtmlOfTemplateString(code);
557
775
  code = await removeCodeTagImport(code);
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import fs from 'node:fs';
2
14
  import path from 'node:path';
3
15
  import * as process from 'node:process';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { readFileSync } from 'node:fs';
2
14
  import * as typescript from 'typescript';
3
15
  /**
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import fs from 'node:fs';
2
14
  import path from 'node:path';
3
15
  import * as process from 'node:process';
@@ -55,7 +67,9 @@ export const loadTypeScriptConfig = (fileName) => {
55
67
  }
56
68
  catch (error) {
57
69
  console.warn(`[loadTypeScriptConfig] Error cargando ${configPath}:`, error);
58
- throw new Error(`No se puede continuar sin un tsconfig.json válido. Error: ${error}`, { cause: error });
70
+ throw new Error(`No se puede continuar sin un tsconfig.json válido. Error: ${error}`, {
71
+ cause: error,
72
+ });
59
73
  }
60
74
  // ✨ FIX #9: Guardar en cache con timestamp
61
75
  configCache = {