brumate 0.4.0 → 0.4.2
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/{boot-DLlRmD9z.d.ts → boot-D3NjfyUX.d.ts} +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-BvDsC6Qr.js → client-Cwr2AfP4.js} +133 -35
- package/dist/client-Cwr2AfP4.js.map +1 -0
- package/dist/{client-DBwL2wKQ.d.ts → client-DNva05jp.d.ts} +20 -7
- package/dist/{defer-CKWZLv2K.js → defer-CxjvJXD_.js} +2 -2
- package/dist/{defer-CKWZLv2K.js.map → defer-CxjvJXD_.js.map} +1 -1
- package/dist/{devtools-4uTPwR_v.js → devtools-BdB_9WB8.js} +4 -4
- package/dist/{devtools-4uTPwR_v.js.map → devtools-BdB_9WB8.js.map} +1 -1
- package/dist/{devtools-panel-Be9pxYgv.js → devtools-panel-Bp6LE4nM.js} +2 -2
- package/dist/{devtools-panel-Be9pxYgv.js.map → devtools-panel-Bp6LE4nM.js.map} +1 -1
- package/dist/{files-WW4RlajL.js → files-BzVNgGOL.js} +2 -2
- package/dist/{files-WW4RlajL.js.map → files-BzVNgGOL.js.map} +1 -1
- package/dist/{html-BtKRyi7g.js → html-t1JpkODI.js} +15 -7
- package/dist/html-t1JpkODI.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/{inspect-Y6y4uNZp.js → inspect-DaZtoKgg.js} +290 -70
- package/dist/inspect-DaZtoKgg.js.map +1 -0
- package/dist/{loader-BjKGJzLN.js → loader-BX8uIUav.js} +2 -2
- package/dist/{loader-BjKGJzLN.js.map → loader-BX8uIUav.js.map} +1 -1
- package/dist/produce-CLABZ8k2.d.ts +11 -0
- package/dist/{produce-B7X9ori9.js → produce-DS-dQaUX.js} +5 -3
- package/dist/produce-DS-dQaUX.js.map +1 -0
- package/dist/{rpc-Q-XkLwFh.js → rpc-t5M5dqs9.js} +3 -3
- package/dist/{rpc-Q-XkLwFh.js.map → rpc-t5M5dqs9.js.map} +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +3 -3
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{server-BvPIg9pT.d.ts → server-BXMH3Z9T.d.ts} +23 -3
- package/dist/{server-DjyOVJtJ.js → server-C6c-GXF4.js} +54 -16
- package/dist/server-C6c-GXF4.js.map +1 -0
- package/dist/shared-CzbnWkVA.d.ts +255 -0
- package/dist/{static-loader-BGgdp_Y5.d.ts → static-loader-BiUaZaag.d.ts} +2 -2
- package/dist/{static-loader-BZR17hSw.js → static-loader-CqQRu-p9.js} +4 -3
- package/dist/{static-loader-BZR17hSw.js.map → static-loader-CqQRu-p9.js.map} +1 -1
- package/dist/{stream-BP5AVmg5.js → stream-CqhuQJwK.js} +4 -4
- package/dist/stream-CqhuQJwK.js.map +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +72 -12
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/client-BvDsC6Qr.js.map +0 -1
- package/dist/html-BtKRyi7g.js.map +0 -1
- package/dist/html-Bw9Qwu6F.d.ts +0 -107
- package/dist/inspect-Y6y4uNZp.js.map +0 -1
- package/dist/produce-B7X9ori9.js.map +0 -1
- package/dist/produce-DIgHBVwL.d.ts +0 -148
- package/dist/server-DjyOVJtJ.js.map +0 -1
- package/dist/stream-BP5AVmg5.js.map +0 -1
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as analyzeProject, B as getLocation, C as isReactiveModule, E as originalPosition,
|
|
1
|
+
import { A as analyzeProject, B as getLocation, C as isReactiveModule, E as originalPosition, I as parse, J as walk, M as importSource, N as importedComponents, O as entryClasses, P as resolveRelative, R as forEachNode, T as builtin, U as analyze, _ as functionId, a as scopeLabel, b as SHARED_QUERY, f as instanceScope, i as report, k as refreshedNames, n as formatReport, p as slotIndex, q as resolveMacros, s as compile, t as anchorLabel, v as getComponentName, w as resolveFromDisk, x as generateShared, y as hash } from "./inspect-DaZtoKgg.js";
|
|
2
2
|
import { s as toNodeHeaders } from "./cookies-Cnbf4w-S.js";
|
|
3
3
|
import { t as LOGO } from "./logo-DQ_OYhBi.js";
|
|
4
|
-
import { _ as reachableFiles, a as findServerFiles, c as hasServerMiddleware, d as serverExports, f as serverModule, g as packageFileName, h as findPackages, i as findScripts, l as hasUseServer, m as findPackage, n as defaultExclude, o as findPackageServerFile, p as serverStubs, r as findFiles, u as isScriptFile, v as resolveComponentPackage } from "./files-
|
|
4
|
+
import { _ as reachableFiles, a as findServerFiles, c as hasServerMiddleware, d as serverExports, f as serverModule, g as packageFileName, h as findPackages, i as findScripts, l as hasUseServer, m as findPackage, n as defaultExclude, o as findPackageServerFile, p as serverStubs, r as findFiles, u as isScriptFile, v as resolveComponentPackage } from "./files-BzVNgGOL.js";
|
|
5
5
|
import { parseSync } from "oxc-parser";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -1730,6 +1730,44 @@ const RENDER_QUERY = "?brumate-render";
|
|
|
1730
1730
|
const SERVER_QUERY = "?brumate-server";
|
|
1731
1731
|
/** Exports `mount` from `brumate/testing`, with the loader of this project's client modules. */
|
|
1732
1732
|
const TESTING = "virtual:brumate/testing";
|
|
1733
|
+
/** The ID of the module of Vite's preload helper, which a client build gets from `preloadHelper`. */
|
|
1734
|
+
const PRELOAD_HELPER = "\0vite/preload-helper.js";
|
|
1735
|
+
/**
|
|
1736
|
+
* Vite's preload helper wraps every `import()` of a client build and preloads the scripts and
|
|
1737
|
+
* the stylesheets of the chunk. This one waits for the stylesheets only, so a lazy chunk shows
|
|
1738
|
+
* styled, and preloads the imports of the chunk. The scripts of a page come with the `Link`
|
|
1739
|
+
* headers of the server (see `hints`).
|
|
1740
|
+
*/
|
|
1741
|
+
function preloadHelper(base, relative) {
|
|
1742
|
+
return [
|
|
1743
|
+
`export const __vitePreload = (load, deps, from) => {`,
|
|
1744
|
+
` const links = [];`,
|
|
1745
|
+
` for (const dep of deps || []) {`,
|
|
1746
|
+
` const href = ${relative ? "new URL(dep, from)" : `new URL(${JSON.stringify(base)} + dep, location.href)`}.href;`,
|
|
1747
|
+
` const rel = dep.endsWith('.css') ? 'stylesheet' : 'modulepreload';`,
|
|
1748
|
+
` let found = false;`,
|
|
1749
|
+
` for (const link of document.getElementsByTagName('link')) {`,
|
|
1750
|
+
` found ||= link.rel === rel && link.href === href;`,
|
|
1751
|
+
` }`,
|
|
1752
|
+
` if (!found) {`,
|
|
1753
|
+
` const link = document.createElement('link');`,
|
|
1754
|
+
` link.rel = rel;`,
|
|
1755
|
+
` link.crossOrigin = '';`,
|
|
1756
|
+
` link.href = href;`,
|
|
1757
|
+
` document.head.appendChild(link);`,
|
|
1758
|
+
` // A script loads along with the chunk, so only a stylesheet is waited for.`,
|
|
1759
|
+
` if (rel === 'stylesheet') {`,
|
|
1760
|
+
` links.push(new Promise((resolve, reject) => {`,
|
|
1761
|
+
` link.onload = resolve;`,
|
|
1762
|
+
` link.onerror = reject;`,
|
|
1763
|
+
` }));`,
|
|
1764
|
+
` }`,
|
|
1765
|
+
` }`,
|
|
1766
|
+
` }`,
|
|
1767
|
+
` return Promise.all(links).then(load);`,
|
|
1768
|
+
`};`
|
|
1769
|
+
].join("\n");
|
|
1770
|
+
}
|
|
1733
1771
|
/** The modules that every page loads early, in the client build. See `hints` of `handleRoute`. */
|
|
1734
1772
|
const HINTS_FILE = ".brumate/hints.json";
|
|
1735
1773
|
/** The dev server answers the devtools panel about a component at this path. */
|
|
@@ -1910,6 +1948,8 @@ function brumate(options = {}) {
|
|
|
1910
1948
|
/** The ID of the build, for skew protection. Undefined on the dev server. */
|
|
1911
1949
|
let buildId;
|
|
1912
1950
|
let base = "/";
|
|
1951
|
+
/** Whether a build writes URLs that need the URL of the importing chunk to resolve. */
|
|
1952
|
+
let relativeUrls = false;
|
|
1913
1953
|
let isSsrBuild = false;
|
|
1914
1954
|
let isServe = false;
|
|
1915
1955
|
/** Component IDs to absolute file paths. */
|
|
@@ -2225,6 +2265,7 @@ function brumate(options = {}) {
|
|
|
2225
2265
|
const id = findComponentId(member);
|
|
2226
2266
|
if (id !== void 0 && !owners.has(id)) owners.set(id, root);
|
|
2227
2267
|
}
|
|
2268
|
+
for (const [id, root] of owners) if (id === root) owners.delete(id);
|
|
2228
2269
|
const bundleLines = [];
|
|
2229
2270
|
for (const root of groups.keys()) bundleLines.push(` ${JSON.stringify(root)}: () => import(${JSON.stringify(`${BUNDLE}${root}`)}),`);
|
|
2230
2271
|
return [
|
|
@@ -2254,8 +2295,9 @@ function brumate(options = {}) {
|
|
|
2254
2295
|
" return Promise.resolve(loaded.get(id));",
|
|
2255
2296
|
" }",
|
|
2256
2297
|
" const waiting = [...pending.values()];",
|
|
2257
|
-
" const
|
|
2258
|
-
"
|
|
2298
|
+
" const root = owners[id] ?? (bundles[id] && id);",
|
|
2299
|
+
" const owner = () => (loaded.has(id) || !root ? loaded.get(id) : loadBundle(root).then(() => loaded.get(id)));",
|
|
2300
|
+
" return waiting.length > 0 ? Promise.allSettled(waiting).then(owner) : root ? owner() : undefined;",
|
|
2259
2301
|
"}"
|
|
2260
2302
|
].join("\n");
|
|
2261
2303
|
}
|
|
@@ -2777,6 +2819,9 @@ function brumate(options = {}) {
|
|
|
2777
2819
|
let coreModule;
|
|
2778
2820
|
let loaderChunk;
|
|
2779
2821
|
let coreChunk;
|
|
2822
|
+
/** The chunks that the loader and the core import, which the server hints at, and the chunks of the bundles. */
|
|
2823
|
+
let startChunks = /* @__PURE__ */ new Set();
|
|
2824
|
+
let bundleChunks = /* @__PURE__ */ new Set();
|
|
2780
2825
|
return {
|
|
2781
2826
|
name: "brumate",
|
|
2782
2827
|
enforce: "pre",
|
|
@@ -2792,18 +2837,19 @@ function brumate(options = {}) {
|
|
|
2792
2837
|
...shared,
|
|
2793
2838
|
...keep
|
|
2794
2839
|
};
|
|
2795
|
-
const resolve = typeof preload === "object" ? preload.resolveDependencies : void 0;
|
|
2796
2840
|
return {
|
|
2797
2841
|
...shared,
|
|
2798
2842
|
build: {
|
|
2799
2843
|
...keep.build,
|
|
2800
|
-
modulePreload: {
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2844
|
+
modulePreload: {
|
|
2845
|
+
...typeof preload === "object" ? preload : {},
|
|
2846
|
+
resolveDependencies(filename, deps) {
|
|
2847
|
+
if (bundleChunks.has(filename)) return [];
|
|
2848
|
+
const rest = [];
|
|
2849
|
+
for (const dep of deps) if (dep !== filename && !startChunks.has(dep)) rest.push(dep);
|
|
2850
|
+
return rest;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2807
2853
|
}
|
|
2808
2854
|
};
|
|
2809
2855
|
}
|
|
@@ -2835,6 +2881,7 @@ function brumate(options = {}) {
|
|
|
2835
2881
|
isServe = config.command === "serve";
|
|
2836
2882
|
outDir = path.resolve(config.root, config.build.outDir);
|
|
2837
2883
|
base = config.base;
|
|
2884
|
+
relativeUrls = config.base === "./" || config.base === "" || !!config.experimental.renderBuiltUrl;
|
|
2838
2885
|
isSsrBuild = Boolean(config.build.ssr);
|
|
2839
2886
|
},
|
|
2840
2887
|
async generateBundle(_output, bundle) {
|
|
@@ -2853,6 +2900,18 @@ function brumate(options = {}) {
|
|
|
2853
2900
|
if (item.moduleIds.includes(`\0${MANIFEST}`)) loaderChunk = item.fileName;
|
|
2854
2901
|
if (coreModule && item.moduleIds.includes(coreModule)) coreChunk = item.fileName;
|
|
2855
2902
|
}
|
|
2903
|
+
startChunks = /* @__PURE__ */ new Set();
|
|
2904
|
+
bundleChunks = /* @__PURE__ */ new Set();
|
|
2905
|
+
function addStart(name) {
|
|
2906
|
+
const found = name === void 0 ? void 0 : bundle[name];
|
|
2907
|
+
if (found?.type === "chunk" && !startChunks.has(name)) {
|
|
2908
|
+
startChunks.add(name);
|
|
2909
|
+
for (const imported of found.imports) addStart(imported);
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
addStart(loaderChunk);
|
|
2913
|
+
addStart(coreChunk);
|
|
2914
|
+
for (const item of Object.values(bundle)) if (item.type === "chunk" && item.facadeModuleId?.startsWith(`\0${BUNDLE}`)) bundleChunks.add(item.fileName);
|
|
2856
2915
|
if (!options.report && !options.budget) return;
|
|
2857
2916
|
const chunks = [];
|
|
2858
2917
|
for (const item of Object.values(bundle)) if (item.type === "chunk") {
|
|
@@ -2981,6 +3040,7 @@ function brumate(options = {}) {
|
|
|
2981
3040
|
} : resolved;
|
|
2982
3041
|
},
|
|
2983
3042
|
async load(id, loadOptions) {
|
|
3043
|
+
if (id === PRELOAD_HELPER && !isServe) return preloadHelper(base, relativeUrls);
|
|
2984
3044
|
if (id.endsWith("?brumate-shared")) {
|
|
2985
3045
|
const module = id.slice(0, -SHARED_QUERY.length);
|
|
2986
3046
|
this.addWatchFile(module);
|