brumate 0.6.2 → 0.7.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/check.d.ts +3 -3
- package/dist/{boot-DkbcqdUz.d.ts → boot-CMy0f_iC.d.ts} +2 -2
- package/dist/cli.js +77 -6
- package/dist/cli.js.map +1 -1
- package/dist/{client-C3vRNuLi.js → client-Bm0XbjHr.js} +274 -113
- package/dist/client-Bm0XbjHr.js.map +1 -0
- package/dist/{client-CqGDbWd_.d.ts → client-DnFF9_lv.d.ts} +40 -14
- package/dist/{client-routes-BtGpYCef.js → client-routes-BmPvNr4s.js} +10 -1
- package/dist/client-routes-BmPvNr4s.js.map +1 -0
- package/dist/{context-btHuB01Z.d.ts → context-BNgBXVUQ.d.ts} +7 -5
- package/dist/{context-CTiSzQRc.js → context-CU4Fpn5a.js} +10 -13
- package/dist/context-CU4Fpn5a.js.map +1 -0
- package/dist/{defer-M18UKyfG.js → defer-BWwxv7Qf.js} +2 -2
- package/dist/{defer-M18UKyfG.js.map → defer-BWwxv7Qf.js.map} +1 -1
- package/dist/{devtools-D9Q7a41M.js → devtools-Cl6AhENB.js} +4 -4
- package/dist/{devtools-D9Q7a41M.js.map → devtools-Cl6AhENB.js.map} +1 -1
- package/dist/{devtools-panel-DTQtljeA.js → devtools-panel-DLIeWcAj.js} +32 -9
- package/dist/devtools-panel-DLIeWcAj.js.map +1 -0
- package/dist/events-LgLdp1R7.js.map +1 -1
- package/dist/{features-CbgII-o7.js → features-DwMYKBIC.js} +6 -2
- package/dist/features-DwMYKBIC.js.map +1 -0
- package/dist/{files-DtDH5AR4.js → files-BuQvpBwF.js} +94 -3
- package/dist/files-BuQvpBwF.js.map +1 -0
- package/dist/{html-t1JpkODI.js → html-Cf5uKhLs.js} +3 -3
- package/dist/html-Cf5uKhLs.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-Bonq6EJO.js → inspect-BSHv1_25.js} +2739 -2080
- package/dist/inspect-BSHv1_25.js.map +1 -0
- package/dist/{loader-C-S3yzep.js → loader-BPNSRA2A.js} +5 -5
- package/dist/{loader-C-S3yzep.js.map → loader-BPNSRA2A.js.map} +1 -1
- package/dist/{rpc-C_znDZ_w.js → rpc-DqfCaYgF.js} +3 -3
- package/dist/{rpc-C_znDZ_w.js.map → rpc-DqfCaYgF.js.map} +1 -1
- package/dist/runtime/bundles.d.ts +1 -1
- package/dist/runtime/bundles.js +2 -0
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +5 -5
- package/dist/runtime/context.d.ts +2 -2
- package/dist/runtime/context.js +1 -1
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.d.ts +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +1 -1
- 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 +4 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +43 -5
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -0
- package/dist/runtime/store.js +1 -0
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{search-params-CM1RWR2P.js → search-params-C64liRBj.js} +34 -9
- package/dist/search-params-C64liRBj.js.map +1 -0
- package/dist/{server-dP_ucRiJ.d.ts → server-0rS5vUW1.d.ts} +37 -10
- package/dist/{server-BcT9icQ4.js → server-BVObWh-w.js} +132 -16
- package/dist/server-BVObWh-w.js.map +1 -0
- package/dist/{shared-CzbnWkVA.d.ts → shared-CuJdWifz.d.ts} +16 -3
- package/dist/{signals-BwD4u22K.d.ts → signals-DBnq9QRW.d.ts} +46 -6
- package/dist/{static-loader-DysAET-w.d.ts → static-loader-BYbXVJDY.d.ts} +2 -2
- package/dist/{static-loader-Bt2WDkY1.js → static-loader-V4V1Oy6G.js} +13 -5
- package/dist/static-loader-V4V1Oy6G.js.map +1 -0
- package/dist/store-BIBAYZo-.js +293 -0
- package/dist/store-BIBAYZo-.js.map +1 -0
- package/dist/store-xlTzAM_r.d.ts +171 -0
- package/dist/{stream-DRjx0keF.js → stream-RXLadXx1.js} +90 -4
- package/dist/stream-RXLadXx1.js.map +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +128 -13
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +349 -79
- package/package.json +5 -1
- package/skills/brumate/SKILL.md +1 -1
- package/skills/brumate/references/errors.md +127 -9
- package/skills/brumate/references/signals.md +37 -30
- package/skills/brumate/references/state.md +3 -2
- package/dist/client-C3vRNuLi.js.map +0 -1
- package/dist/client-routes-BtGpYCef.js.map +0 -1
- package/dist/context-CTiSzQRc.js.map +0 -1
- package/dist/devtools-panel-DTQtljeA.js.map +0 -1
- package/dist/features-CbgII-o7.js.map +0 -1
- package/dist/files-DtDH5AR4.js.map +0 -1
- package/dist/html-t1JpkODI.js.map +0 -1
- package/dist/inspect-Bonq6EJO.js.map +0 -1
- package/dist/search-params-CM1RWR2P.js.map +0 -1
- package/dist/server-BcT9icQ4.js.map +0 -1
- package/dist/static-loader-Bt2WDkY1.js.map +0 -1
- package/dist/stream-DRjx0keF.js.map +0 -1
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as analyzeProject,
|
|
1
|
+
import { A as analyzeProject, C as isReactiveModule, E as originalPosition, G as bridgeModuleId, H as resolveMacros, I as parse, J as nameBridges, K as hasBridge, M as importSource, N as importedComponents, O as entryClasses, P as resolveRelative, Q as getLocation, R as forEachNode, T as builtin, U as walk, _ 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 mayHaveBridge, s as compile, t as anchorLabel, v as getComponentName, w as resolveFromDisk, x as generateShared, y as hash, z as analyze } from "./inspect-BSHv1_25.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
|
|
4
|
+
import { _ as findPackages, a as findScripts, b as resolveComponentPackage, d as isScriptFile, f as serverExports, g as findPackage, h as findBridgePackages, i as findFiles, l as hasServerMiddleware, m as serverStubs, n as defaultExclude, o as findServerFiles, p as serverModule, r as findBridgeFiles, s as findPackageServerFile, u as hasUseServer, v as packageFileName, y as reachableFiles } from "./files-BuQvpBwF.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";
|
|
@@ -129,7 +129,9 @@ function noFeatures() {
|
|
|
129
129
|
routes: false,
|
|
130
130
|
loading: false,
|
|
131
131
|
rootWait: false,
|
|
132
|
-
searchParams: false
|
|
132
|
+
searchParams: false,
|
|
133
|
+
stores: false,
|
|
134
|
+
bridges: false
|
|
133
135
|
};
|
|
134
136
|
}
|
|
135
137
|
/** Every feature, for a build that compiles components in the browser. */
|
|
@@ -163,7 +165,9 @@ function getFeatures(result) {
|
|
|
163
165
|
routes: /\b(?:routeContext|navigationContext)\b/.test(all),
|
|
164
166
|
loading: /\$\$b\.loading\(/.test(client),
|
|
165
167
|
rootWait: /\$\$b\.wait\(/.test(client),
|
|
166
|
-
searchParams: /\$\$b\.(?:searchParam|paramEffect)\(/.test(all)
|
|
168
|
+
searchParams: /\$\$b\.(?:searchParam|paramEffect)\(/.test(all),
|
|
169
|
+
stores: /\$\$(?:b|ctx)\.(?:toStore|consumeStore)\(|['"]brumate\/store['"]/.test(all),
|
|
170
|
+
bridges: /\$\$nameBridge\(/.test(all)
|
|
167
171
|
};
|
|
168
172
|
}
|
|
169
173
|
/** The features of several components together. */
|
|
@@ -187,6 +191,8 @@ function joinFeatures(all) {
|
|
|
187
191
|
joined.loading ||= features.loading;
|
|
188
192
|
joined.rootWait ||= features.rootWait;
|
|
189
193
|
joined.searchParams ||= features.searchParams;
|
|
194
|
+
joined.stores ||= features.stores;
|
|
195
|
+
joined.bridges ||= features.bridges;
|
|
190
196
|
}
|
|
191
197
|
return joined;
|
|
192
198
|
}
|
|
@@ -208,7 +214,9 @@ const GLOBALS = {
|
|
|
208
214
|
routes: "__BRUMATE_HAS_ROUTES__",
|
|
209
215
|
loading: "__BRUMATE_HAS_LOADING__",
|
|
210
216
|
rootWait: "__BRUMATE_HAS_ROOT_WAIT__",
|
|
211
|
-
searchParams: "__BRUMATE_HAS_SEARCH_PARAMS__"
|
|
217
|
+
searchParams: "__BRUMATE_HAS_SEARCH_PARAMS__",
|
|
218
|
+
stores: "__BRUMATE_HAS_STORES__",
|
|
219
|
+
bridges: "__BRUMATE_HAS_BRIDGES__"
|
|
212
220
|
};
|
|
213
221
|
/** True for code that reads a feature, such as the core. */
|
|
214
222
|
function readsFeatures(code) {
|
|
@@ -1830,6 +1838,10 @@ function packagesKey(list) {
|
|
|
1830
1838
|
]);
|
|
1831
1839
|
return JSON.stringify(rows);
|
|
1832
1840
|
}
|
|
1841
|
+
/** The names of a `noExternal` setting as a list. */
|
|
1842
|
+
function toList(value) {
|
|
1843
|
+
return Array.isArray(value) ? value : [];
|
|
1844
|
+
}
|
|
1833
1845
|
/** Skips the `node_modules` and hidden directories of a package of components. */
|
|
1834
1846
|
function packageExclude(directory) {
|
|
1835
1847
|
return directory === "node_modules" || directory.startsWith(".");
|
|
@@ -2007,6 +2019,8 @@ function brumate(options = {}) {
|
|
|
2007
2019
|
let refreshed;
|
|
2008
2020
|
/** The dependencies of the app that ship `.brm` files. See `packages.ts`. */
|
|
2009
2021
|
let packages = [];
|
|
2022
|
+
/** Installed packages with a `bridge`, which are not packages of components, and their files. */
|
|
2023
|
+
let bridgePackages = [];
|
|
2010
2024
|
function relative(file) {
|
|
2011
2025
|
return normalizePath(path.relative(root, file));
|
|
2012
2026
|
}
|
|
@@ -2025,6 +2039,8 @@ function brumate(options = {}) {
|
|
|
2025
2039
|
}
|
|
2026
2040
|
/** Files of server functions: scripts whose first statement is `'use server'`, by ID. */
|
|
2027
2041
|
const serverFiles = /* @__PURE__ */ new Map();
|
|
2042
|
+
/** The script files with a `bridge`, by the ID of their module. The browser loads them by it. */
|
|
2043
|
+
const bridgeFiles = /* @__PURE__ */ new Map();
|
|
2028
2044
|
/** The scripts of the app, when it uses packages of components. */
|
|
2029
2045
|
let appScripts = [];
|
|
2030
2046
|
/** The ID of a function that a component imports from a 'use server' file, by a relative path. */
|
|
@@ -2048,6 +2064,12 @@ function brumate(options = {}) {
|
|
|
2048
2064
|
}
|
|
2049
2065
|
return found && functionId(serverFileId(normalizePath(found)), name, !isServe);
|
|
2050
2066
|
}
|
|
2067
|
+
function bridgeId(file) {
|
|
2068
|
+
let normalized = normalizePath(file);
|
|
2069
|
+
if (bridgePackages.length > 0 && normalized.includes("/node_modules/") && existsSync(normalized)) normalized = normalizePath(realpathSync(normalized));
|
|
2070
|
+
for (const item of bridgePackages) if (normalized.startsWith(`${item.root}/`)) return bridgeModuleId(`${item.name}/${normalized.slice(item.root.length + 1)}`);
|
|
2071
|
+
return bridgeModuleId(getFileName(file));
|
|
2072
|
+
}
|
|
2051
2073
|
function serverFileId(file) {
|
|
2052
2074
|
return `${path.basename(file).replace(/\.[^.]+$/, "")}_${hash(getFileName(file))}`;
|
|
2053
2075
|
}
|
|
@@ -2062,6 +2084,7 @@ function brumate(options = {}) {
|
|
|
2062
2084
|
return !findPackage(packages, file);
|
|
2063
2085
|
}
|
|
2064
2086
|
const searches = [findFiles(root, exclude), findServerFiles(root, exclude)];
|
|
2087
|
+
const bridged = Promise.all([findBridgeFiles(root, exclude), ...directories.map((directory) => findBridgeFiles(directory, packageExclude))]);
|
|
2065
2088
|
for (const directory of directories) searches.push(findFiles(directory, packageExclude), findServerFiles(directory, packageExclude));
|
|
2066
2089
|
const [own, ownServer, ...found] = await Promise.all(searches);
|
|
2067
2090
|
const scripts = [];
|
|
@@ -2071,6 +2094,9 @@ function brumate(options = {}) {
|
|
|
2071
2094
|
appScripts = scripts;
|
|
2072
2095
|
files.clear();
|
|
2073
2096
|
serverFiles.clear();
|
|
2097
|
+
bridgeFiles.clear();
|
|
2098
|
+
for (const list of await bridged) for (const file of list) bridgeFiles.set(bridgeId(file), file);
|
|
2099
|
+
for (const item of bridgePackages) for (const file of item.files) bridgeFiles.set(bridgeId(file), file);
|
|
2074
2100
|
for (const file of own) if (ownFile(file)) files.set(componentId(file), file);
|
|
2075
2101
|
for (const file of ownServer) if (ownFile(file)) serverFiles.set(serverFileId(file), file);
|
|
2076
2102
|
for (const [index, list] of found.entries()) for (const file of list) if (index % 2 === 0) files.set(componentId(file), file);
|
|
@@ -2145,10 +2171,14 @@ function brumate(options = {}) {
|
|
|
2145
2171
|
break;
|
|
2146
2172
|
}
|
|
2147
2173
|
features.lateMarkup ||= options.navigate !== false || loading;
|
|
2174
|
+
features.bridges ||= bridgeFiles.size > 0;
|
|
2175
|
+
features.stores ||= features.bridges;
|
|
2148
2176
|
features.routes ||= options.navigate !== false;
|
|
2149
2177
|
if (!features.routes) {
|
|
2150
2178
|
const own = path.resolve(import.meta.dirname, "..").split(path.sep).join("/");
|
|
2151
|
-
const
|
|
2179
|
+
const scripts = [];
|
|
2180
|
+
for (const file of /* @__PURE__ */ new Set([...await findScripts(root, exclude), ...reachable()])) if (!file.startsWith(`${own}/dist/`) && !file.startsWith(`${own}/src/`)) scripts.push(file);
|
|
2181
|
+
const texts = await inBatches(scripts, (file) => readFile(file, "utf8").catch(() => ""));
|
|
2152
2182
|
for (const text of texts) if (ROUTE_CONTEXTS.test(text)) {
|
|
2153
2183
|
features.routes = true;
|
|
2154
2184
|
break;
|
|
@@ -2306,6 +2336,13 @@ function brumate(options = {}) {
|
|
|
2306
2336
|
let builtHints;
|
|
2307
2337
|
/** The IDs of the components in each bundle of the client build, by root, for `hints.json`. */
|
|
2308
2338
|
const bundleMembers = /* @__PURE__ */ new Map();
|
|
2339
|
+
/** `bridges`: the loaders of the modules with a `bridge`, by module ID. */
|
|
2340
|
+
function bridgeLoaders() {
|
|
2341
|
+
const lines = ["const bridges = {"];
|
|
2342
|
+
for (const [id, file] of bridgeFiles) lines.push(` ${JSON.stringify(id)}: () => import(${JSON.stringify(file)}),`);
|
|
2343
|
+
lines.push("};");
|
|
2344
|
+
return lines.join("\n");
|
|
2345
|
+
}
|
|
2309
2346
|
async function manifest() {
|
|
2310
2347
|
const list = [...files];
|
|
2311
2348
|
const needed = await inBatches(list, async ([, file]) => isServe || (await compileFile(file)).result.clientCode);
|
|
@@ -2324,6 +2361,14 @@ function brumate(options = {}) {
|
|
|
2324
2361
|
}
|
|
2325
2362
|
bundleMembers.set(root, ids);
|
|
2326
2363
|
}
|
|
2364
|
+
if (bridgeFiles.size > 0) return [
|
|
2365
|
+
"import { load as loadBundle } from 'brumate/bundles';",
|
|
2366
|
+
bridgeLoaders(),
|
|
2367
|
+
"export function load(id) {",
|
|
2368
|
+
" return bridges[id] ? bridges[id]() : loadBundle(id);",
|
|
2369
|
+
"}",
|
|
2370
|
+
`load.all = () => import(${JSON.stringify(BUNDLES)});`
|
|
2371
|
+
].join("\n");
|
|
2327
2372
|
return [
|
|
2328
2373
|
"import { load } from 'brumate/bundles';",
|
|
2329
2374
|
`load.all = () => import(${JSON.stringify(BUNDLES)});`,
|
|
@@ -2333,10 +2378,19 @@ function brumate(options = {}) {
|
|
|
2333
2378
|
const entries = [];
|
|
2334
2379
|
for (const [id, file] of kept) entries.push(` ${JSON.stringify(id)}: () => import(${JSON.stringify(`${file}${CLIENT_QUERY}`)}),`);
|
|
2335
2380
|
return [
|
|
2381
|
+
...bridgeFiles.size > 0 ? [bridgeLoaders()] : [],
|
|
2336
2382
|
"const modules = {",
|
|
2337
2383
|
...entries,
|
|
2338
2384
|
"};",
|
|
2339
2385
|
"export function load(id) {",
|
|
2386
|
+
...bridgeFiles.size > 0 ? [
|
|
2387
|
+
" if (bridges[id]) {",
|
|
2388
|
+
" return bridges[id]();",
|
|
2389
|
+
" }"
|
|
2390
|
+
] : [],
|
|
2391
|
+
" if (id.startsWith('bridge:')) {",
|
|
2392
|
+
" id = id.slice(7);",
|
|
2393
|
+
" }",
|
|
2340
2394
|
...isServe ? [
|
|
2341
2395
|
" const module = modules[id];",
|
|
2342
2396
|
" if (!module) {",
|
|
@@ -2488,6 +2542,21 @@ function brumate(options = {}) {
|
|
|
2488
2542
|
const where = at.file === void 0 ? getLocation(source, at.offset) : void 0;
|
|
2489
2543
|
return where ? `${site.label} ${where.line}:${where.column}` : site.label;
|
|
2490
2544
|
}
|
|
2545
|
+
const moduleSources = /* @__PURE__ */ new Map();
|
|
2546
|
+
function placeOf(offset) {
|
|
2547
|
+
const at = result.locate(offset);
|
|
2548
|
+
if (at.file === void 0) return getLocation(source, at.offset);
|
|
2549
|
+
if (!moduleSources.has(at.file)) try {
|
|
2550
|
+
moduleSources.set(at.file, readFileSync(at.file, "utf8"));
|
|
2551
|
+
} catch {
|
|
2552
|
+
moduleSources.set(at.file, void 0);
|
|
2553
|
+
}
|
|
2554
|
+
const text = moduleSources.get(at.file);
|
|
2555
|
+
return text === void 0 ? void 0 : {
|
|
2556
|
+
...getLocation(text, at.offset),
|
|
2557
|
+
file: at.file
|
|
2558
|
+
};
|
|
2559
|
+
}
|
|
2491
2560
|
const liveSites = /* @__PURE__ */ new Set();
|
|
2492
2561
|
for (const node of plan.graph.live) if ("site" in node) liveSites.add(node.site);
|
|
2493
2562
|
for (const layout of plan.scopes.values()) {
|
|
@@ -2514,20 +2583,22 @@ function brumate(options = {}) {
|
|
|
2514
2583
|
const graphNodes = [];
|
|
2515
2584
|
for (const node of nodes) {
|
|
2516
2585
|
if (node.kind === "source" || node.kind === "memo") {
|
|
2586
|
+
const at = placeOf(node.declaration.range.start);
|
|
2517
2587
|
graphNodes.push({
|
|
2518
2588
|
kind: node.kind === "memo" ? "memo" : node.declaration.kind,
|
|
2519
2589
|
label: node.declaration.name,
|
|
2520
2590
|
scope: instanceScope(plan, node.declaration.scope).id,
|
|
2521
|
-
slot: slotIndex(plan, node.declaration)
|
|
2591
|
+
slot: slotIndex(plan, node.declaration),
|
|
2592
|
+
...at ? { at } : {}
|
|
2522
2593
|
});
|
|
2523
2594
|
continue;
|
|
2524
2595
|
}
|
|
2525
|
-
const at =
|
|
2526
|
-
const where = at.file === void 0 ? getLocation(source, at.offset) : void 0;
|
|
2596
|
+
const at = placeOf(node.site.range.start);
|
|
2527
2597
|
graphNodes.push({
|
|
2528
2598
|
kind: node.kind,
|
|
2529
|
-
label:
|
|
2530
|
-
scope: instanceScope(plan, node.site.scope).id
|
|
2599
|
+
label: node.site.label,
|
|
2600
|
+
scope: instanceScope(plan, node.site.scope).id,
|
|
2601
|
+
...at ? { at } : {}
|
|
2531
2602
|
});
|
|
2532
2603
|
}
|
|
2533
2604
|
const graphEdges = [];
|
|
@@ -2859,9 +2930,36 @@ function brumate(options = {}) {
|
|
|
2859
2930
|
return {
|
|
2860
2931
|
name: "brumate",
|
|
2861
2932
|
enforce: "pre",
|
|
2862
|
-
config(config, env) {
|
|
2863
|
-
|
|
2933
|
+
async config(config, env) {
|
|
2934
|
+
const appRoot = path.resolve(config.root ?? process.cwd());
|
|
2935
|
+
packages = findPackages(appRoot);
|
|
2936
|
+
bridgePackages = [];
|
|
2937
|
+
for (const item of findBridgePackages(appRoot)) {
|
|
2938
|
+
const files = await findBridgeFiles(item.root, packageExclude);
|
|
2939
|
+
if (files.length > 0) bridgePackages.push({
|
|
2940
|
+
...item,
|
|
2941
|
+
files
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2864
2944
|
const shared = packageConfig(config);
|
|
2945
|
+
if (bridgePackages.length > 0) {
|
|
2946
|
+
const names = [...new Set(bridgePackages.map((item) => item.package))];
|
|
2947
|
+
const excluded = /* @__PURE__ */ new Set([...shared.optimizeDeps?.exclude ?? [], ...names]);
|
|
2948
|
+
const nested = [];
|
|
2949
|
+
for (const item of bridgePackages) for (const dependency of item.dependencies) if (!excluded.has(dependency)) nested.push(`${item.package} > ${dependency}`);
|
|
2950
|
+
shared.optimizeDeps = {
|
|
2951
|
+
include: [...shared.optimizeDeps?.include ?? [], ...new Set(nested)],
|
|
2952
|
+
exclude: [...shared.optimizeDeps?.exclude ?? [], ...names]
|
|
2953
|
+
};
|
|
2954
|
+
shared.ssr = {
|
|
2955
|
+
...shared.ssr,
|
|
2956
|
+
noExternal: [...toList(shared.ssr?.noExternal), ...names]
|
|
2957
|
+
};
|
|
2958
|
+
shared.resolve = {
|
|
2959
|
+
...shared.resolve,
|
|
2960
|
+
dedupe: ["brumate"]
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2865
2963
|
const hmr = config.server?.hmr;
|
|
2866
2964
|
if (env.command === "serve" && options.devtools !== false && hmr !== false && (typeof hmr !== "object" || hmr.overlay === void 0)) shared.server = { hmr: { overlay: false } };
|
|
2867
2965
|
if (!env.isSsrBuild) {
|
|
@@ -3272,6 +3370,15 @@ function brumate(options = {}) {
|
|
|
3272
3370
|
} catch (error) {
|
|
3273
3371
|
this.error(error.message);
|
|
3274
3372
|
}
|
|
3373
|
+
if (file && isScriptFile(file) && mayHaveBridge(code)) try {
|
|
3374
|
+
const named = nameBridges(code, file, bridgeId(file));
|
|
3375
|
+
if (named) return {
|
|
3376
|
+
code: named,
|
|
3377
|
+
map: null
|
|
3378
|
+
};
|
|
3379
|
+
} catch (error) {
|
|
3380
|
+
this.error(error.message);
|
|
3381
|
+
}
|
|
3275
3382
|
const shared = isReactiveModule(file ?? "") && id.endsWith("?brumate-shared");
|
|
3276
3383
|
if (!file?.endsWith(".brm") && !shared) return;
|
|
3277
3384
|
const result = await transformWithOxc(code, `${file}.ts`, {
|
|
@@ -3312,6 +3419,14 @@ function brumate(options = {}) {
|
|
|
3312
3419
|
appScripts = rest;
|
|
3313
3420
|
if (event !== "unlink") appScripts.push(normalized);
|
|
3314
3421
|
}
|
|
3422
|
+
const bridged = bridgeId(normalized);
|
|
3423
|
+
const hadBridge = bridgeFiles.has(bridged);
|
|
3424
|
+
const nowBridge = event !== "unlink" && existsSync(file) && hasBridge(readFileSync(file, "utf8"), file);
|
|
3425
|
+
if (nowBridge) bridgeFiles.set(bridged, normalized);
|
|
3426
|
+
else bridgeFiles.delete(bridged);
|
|
3427
|
+
if (hadBridge !== nowBridge) {
|
|
3428
|
+
for (const module of server.moduleGraph.idToModuleMap.values()) if (module.id === `\0${MANIFEST}`) server.moduleGraph.invalidateModule(module);
|
|
3429
|
+
}
|
|
3315
3430
|
const id = serverFileId(normalized);
|
|
3316
3431
|
const before = serverFiles.has(id);
|
|
3317
3432
|
const after = event !== "unlink" && existsSync(file) && hasUseServer(readFileSync(file, "utf8"));
|