vatts 1.2.0-test.0 → 1.2.0-test.1
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/loaders.js +5 -9
- package/package.json +1 -1
package/dist/loaders.js
CHANGED
|
@@ -113,6 +113,7 @@ function registerLoaders(options = {}) {
|
|
|
113
113
|
console.error(`Erro ao parsear ${filename}:`, errors);
|
|
114
114
|
}
|
|
115
115
|
// 2. Compilação do Script (<script> ou <script setup>)
|
|
116
|
+
// Padrão: Se não houver script, definimos um objeto vazio
|
|
116
117
|
let scriptContent = 'const _sfc_main = {};';
|
|
117
118
|
let bindings = undefined;
|
|
118
119
|
if (descriptor.script || descriptor.scriptSetup) {
|
|
@@ -122,14 +123,14 @@ function registerLoaders(options = {}) {
|
|
|
122
123
|
isProd: false,
|
|
123
124
|
inlineTemplate: false
|
|
124
125
|
});
|
|
125
|
-
//
|
|
126
|
-
//
|
|
126
|
+
// Lógica de substituição do export default
|
|
127
|
+
// 1. Procura por "export default" (com ou sem espaços extras)
|
|
127
128
|
if (compiledScript.content.match(/export\s+default/)) {
|
|
128
129
|
scriptContent = compiledScript.content.replace(/export\s+default/, 'const _sfc_main =');
|
|
129
130
|
}
|
|
130
131
|
else {
|
|
131
|
-
//
|
|
132
|
-
//
|
|
132
|
+
// 2. Se não achou export default (ex: arquivo só tem "export const config"),
|
|
133
|
+
// mantemos o conteúdo original e ADICIONAMOS a definição do _sfc_main manualmente.
|
|
133
134
|
scriptContent = compiledScript.content + '\nconst _sfc_main = {};';
|
|
134
135
|
}
|
|
135
136
|
bindings = compiledScript.bindings;
|
|
@@ -165,7 +166,6 @@ function registerLoaders(options = {}) {
|
|
|
165
166
|
${templateContent}
|
|
166
167
|
|
|
167
168
|
// Anexa a função de renderização SSR ao componente principal
|
|
168
|
-
// Usa verificação de tipo segura para evitar ReferenceError na checagem
|
|
169
169
|
if (typeof _sfc_main !== 'undefined') {
|
|
170
170
|
if (typeof ssrRender !== 'undefined') {
|
|
171
171
|
_sfc_main.ssrRender = ssrRender;
|
|
@@ -173,9 +173,6 @@ function registerLoaders(options = {}) {
|
|
|
173
173
|
if (typeof render !== 'undefined') {
|
|
174
174
|
_sfc_main.render = render;
|
|
175
175
|
}
|
|
176
|
-
} else {
|
|
177
|
-
// Safety net: Se _sfc_main não foi definido acima, define agora para não quebrar o export abaixo
|
|
178
|
-
var _sfc_main = {};
|
|
179
176
|
}
|
|
180
177
|
|
|
181
178
|
export default _sfc_main;
|
|
@@ -194,7 +191,6 @@ function registerLoaders(options = {}) {
|
|
|
194
191
|
console.error(`\n--- Vatts Loader Debug ---`);
|
|
195
192
|
console.error(`Falha fatal ao carregar: ${filename}`);
|
|
196
193
|
console.error(`Erro original: ${err.message}`);
|
|
197
|
-
// Mostra um snippet do código gerado para facilitar a correção
|
|
198
194
|
if (finalEsm) {
|
|
199
195
|
console.error(`\n[DEBUG] Código gerado (Snippet):`);
|
|
200
196
|
console.error(finalEsm.split('\n').slice(0, 30).join('\n') + '\n...');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vatts",
|
|
3
|
-
"version": "1.2.0-test.
|
|
3
|
+
"version": "1.2.0-test.1",
|
|
4
4
|
"description": "Vatts.js is a high-level framework for building web applications with ease and speed. It provides a robust set of tools and features to streamline development and enhance productivity.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "itsmuzin",
|