vitral 0.12.0 → 0.12.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.
@@ -29,6 +29,25 @@ async function exportOrigins(ctx, file, cache) {
29
29
  }
30
30
  return origins(file, parsed, /* @__PURE__ */ new Map(), []);
31
31
  }
32
+ async function exportSources(ctx, file, cache) {
33
+ await exportOrigins(ctx, file, cache);
34
+ const parsed = /* @__PURE__ */ new Map();
35
+ for (const [f, p] of cache) parsed.set(f, await p);
36
+ return sources(file, parsed, /* @__PURE__ */ new Map(), []);
37
+ }
38
+ function sources(file, parsed, memo, stack) {
39
+ const p = parsed.get(file);
40
+ if (!p || stack.includes(file)) return /* @__PURE__ */ new Map();
41
+ const known = memo.get(file);
42
+ if (known) return known;
43
+ const next = [...stack, file];
44
+ const out = /* @__PURE__ */ new Map();
45
+ for (const name of p.local.keys()) out.set(name, [file, name]);
46
+ for (const n of p.named) out.set(n.exported, n.source && sources(n.source, parsed, memo, next).get(n.name) || [file, n.exported]);
47
+ for (const s of p.star) for (const [name, v] of sources(s, parsed, memo, next)) if (name !== "default" && !out.has(name)) out.set(name, v);
48
+ memo.set(file, out);
49
+ return out;
50
+ }
32
51
  function origins(file, parsed, memo, stack) {
33
52
  if (stack.includes(file)) return /* @__PURE__ */ new Map();
34
53
  const known = memo.get(file);
@@ -257,6 +276,32 @@ function dedupeHooks(entry, getGroups) {
257
276
  origins2 = /* @__PURE__ */ new Map();
258
277
  exports.clear();
259
278
  },
279
+ /**
280
+ * Depois do build dividido: arquivos de um grupo que o código principal
281
+ * alcança sem passar pela cópia própria. Eles baixam e rodam mesmo com o
282
+ * pacote oferecido pelo host; o aviso mostra um caminho até cada grupo.
283
+ */
284
+ leaks(ctx, root) {
285
+ const from = /* @__PURE__ */ new Map();
286
+ const stack = ["\0" + BOOT];
287
+ while (stack.length) {
288
+ const id = stack.pop();
289
+ const m = ctx.getModuleInfo(id);
290
+ for (const d of [...m?.importedIds ?? [], ...m?.dynamicallyImportedIds ?? []]) if (!d.startsWith(OWN) && !from.has(d)) from.set(d, id), stack.push(d);
291
+ }
292
+ const r = norm(root) + "/";
293
+ const show = (id) => {
294
+ const v = /^\0([\w:-]*?:)(\/.*)$/.exec(id);
295
+ return v ? v[1] + show(v[2]) : norm(id).startsWith(r) ? norm(id).slice(r.length) : id.replace(/^\0/, "");
296
+ };
297
+ for (const g of getGroups()) {
298
+ const found = [...from.keys()].filter((id) => !id.startsWith("\0") && inside(g, id));
299
+ if (!found.length) continue;
300
+ const chain = [found[0]];
301
+ while (from.has(chain[0]) && !chain[0].startsWith("\0" + BOOT)) chain.unshift(from.get(chain[0]));
302
+ ctx.warn?.(`dedupe: ${found.length} arquivo(s) de ${g.name} entram no c\xF3digo principal do remote, fora da c\xF3pia pr\xF3pria: baixam e rodam mesmo com o pacote oferecido pelo host. Um caminho: ${chain.slice(1).map(show).join(" \u2192 ")}`);
303
+ }
304
+ },
260
305
  /** Algum grupo troca também os imports que chegam a arquivos do pacote? */
261
306
  files: () => getGroups().some((g) => g.files),
262
307
  resolveId: {
@@ -324,14 +369,18 @@ export { v${i} as ${JSON.stringify(n)} }
324
369
  ` + (own.has("default") ? `export { default } from ${f}
325
370
  ` : "");
326
371
  }
372
+ const from = rest.length ? await exportSources(ctx, file, exports) : /* @__PURE__ */ new Map();
373
+ const src = (n) => from.get(n) ?? [file, n];
374
+ const rel = (x) => x.slice(g.dir.length + 1);
327
375
  if (rest.length)
328
- ctx.warn?.(`dedupe: ${file.slice(g.dir.length + 1)}: ${rest.join(", ")} n\xE3o sai(em) por nenhum export de ${g.name}: esses nomes v\xEAm de uma c\xF3pia pr\xF3pria deste arquivo`);
376
+ ctx.warn?.(`dedupe: ${rel(file)}: ${rest.join(", ")} n\xE3o sai(em) por nenhum export de ${g.name}: esses nomes v\xEAm de uma c\xF3pia pr\xF3pria de ${[...new Set(rest.map((n) => rel(src(n)[0])))].join(", ")}, que entra no c\xF3digo principal do remote`);
377
+ const q = (n) => n === "default" ? "default" : JSON.stringify(n);
329
378
  return `import { deps } from ${JSON.stringify(DEPS)}
330
379
  ` + shared.map(([name, v], i) => `const v${i} = deps[${JSON.stringify(v.spec)}][${JSON.stringify(v.name)}]
331
380
  ` + (name === "default" ? `export default v${i}
332
381
  ` : `export { v${i} as ${JSON.stringify(name)} }
333
- `)).join("") + (rest.length ? `export { ${rest.map((n) => n === "default" ? "default" : JSON.stringify(n)).join(", ")} } from ${f}
334
- ` : "");
382
+ `)).join("") + rest.map((n) => `export { ${q(src(n)[1])} as ${q(n)} } from ${JSON.stringify(src(n)[0])}
383
+ `).join("");
335
384
  }
336
385
  return null;
337
386
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  subpaths
3
- } from "./chunk-SOENZNXO.js";
3
+ } from "./chunk-B23S6737.js";
4
4
  import {
5
5
  hintsOf
6
6
  } from "./chunk-QQWE5J6U.js";
package/dist/vite.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  dedupeIds,
5
5
  groups,
6
6
  usedNames
7
- } from "./chunk-SOENZNXO.js";
7
+ } from "./chunk-B23S6737.js";
8
8
  import {
9
9
  extractProps,
10
10
  typesFile
@@ -1214,6 +1214,9 @@ function vitral(options = {}) {
1214
1214
  if (serve && options.scopeCss !== false) return scopeDevCss(code, id, scopeName(), options.scopeCss === "native");
1215
1215
  }
1216
1216
  },
1217
+ generateBundle(_, bundle) {
1218
+ if (dedupe && !serve && isSplit(bundle)) hooks.leaks(this, root);
1219
+ },
1217
1220
  writeBundle(_, bundle) {
1218
1221
  if (options.sbom) bundledFiles(bundle, modules);
1219
1222
  if (isSplit(bundle)) return void (split = collect(outDir, bundle));
package/dist/vue.d.ts CHANGED
@@ -127,9 +127,9 @@ declare const VitralRemote: vue.DefineComponent<vue.ExtractPropTypes<{
127
127
  onError?: ((...args: any[]) => any) | undefined;
128
128
  onReady?: ((...args: any[]) => any) | undefined;
129
129
  }>, {
130
+ name: string;
130
131
  isolate: Isolation;
131
132
  priority: RequestPriority;
132
- name: string;
133
133
  loading: Loading;
134
134
  src: string;
135
135
  props: Props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitral",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Micro-frontends com qualquer framework, sem configurar build no host. React, Next.js, Vue, Nuxt, Angular, Svelte e outros na mesma página.",
5
5
  "keywords": [
6
6
  "micro-frontend",