@powerhousedao/builder-tools 6.2.3-dev.77 → 6.2.3-dev.79
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/index.d.mts
CHANGED
|
@@ -279,7 +279,9 @@ export declare function generateConnectRoutes(projectRoot: string, routesDir: st
|
|
|
279
279
|
/** Connect's route files, as the generated tree imports them: by Connect's
|
|
280
280
|
* package name, which a project depends on. */
|
|
281
281
|
export declare const CONNECT_ROUTES_SPECIFIER = "@powerhousedao/connect/routes";
|
|
282
|
-
/** Generates the tree when the project has routes
|
|
282
|
+
/** Generates the tree when the project has routes. Without them, a tree there
|
|
283
|
+
* is rewritten with Connect's routes only, never removed: Studio routes
|
|
284
|
+
* through it, and a removed folder's routes leave it, as tsc needs. */
|
|
283
285
|
export declare function syncConnectRoutes(projectRoot: string, routesDir?: string | undefined): Promise<void>;
|
|
284
286
|
/** What Connect's route files import, besides each other. */
|
|
285
287
|
export declare const CONNECT_ROUTE_FILE_DEPS: string[];
|
|
@@ -298,8 +300,12 @@ export declare const CONNECT_ROUTE_FILE_DEPS: string[];
|
|
|
298
300
|
*/
|
|
299
301
|
export declare function connectRouteFileDeps(connectDir: string): string[];
|
|
300
302
|
/** Mounts a project's routes folder over Connect's routes; without one,
|
|
301
|
-
* Connect keeps its prebuilt tree and no router plugin runs.
|
|
303
|
+
* Connect keeps its prebuilt tree and no router plugin runs. Dev may pass a
|
|
304
|
+
* folder that does not exist yet: it is mounted once it does. */
|
|
302
305
|
export declare function connectRoutes(projectRoot: string, routesDir?: string | false | undefined): ConnectRoutes;
|
|
306
|
+
/** Dev: rewrites the tree as files and folders under the routes folder come and
|
|
307
|
+
* go, the folder itself included; the router plugin follows the tree. */
|
|
308
|
+
export declare function connectRoutesWatcher(projectRoot: string, routesDir: string, config: ReturnType<typeof connectRoutesGeneratorConfig>): Plugin;
|
|
303
309
|
/** One chunk for the router and the project's route configs, which the split
|
|
304
310
|
* route components would otherwise spread over several shared chunks. */
|
|
305
311
|
export declare function connectRouterChunkGroups(routesDir?: string | false): ({
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/vite-plugins/project-brand.ts","../connect-utils/vite-plugins/app-shell.ts","../connect-utils/vite-plugins/build-hash.ts","../connect-utils/vite-plugins/connect-routes.ts","../connect-utils/vite-plugins/host-stylesheet.ts","../connect-utils/externalize-vendor.ts","../connect-utils/reactor-worker-build.ts","../connect-utils/worker-packages-build.ts","../connect-utils/types.ts","../connect-utils/helpers.ts","../connect-utils/runtime-config-schema.ts","../connect-utils/vite-config.ts","../connect-utils/vite-plugins/dynamic-base.ts","../connect-utils/vite-plugins/ph-config.ts","../connect-utils/vite-plugins/theme-boot.ts","../connect-utils/vite-plugins/vendor-import-map.ts"],"mappings":";;;;;;qBAAa;qBACA;qBACA;qBACA;;;KC4QD;;EAEV;;EAEA;EACA;;KAGU,gBAAgB;EAC1B,WAAW,YAAY;EACvB;;;;;qBCzQW;YAED;;EAEV;;EAEA;;;YAIU;YAEA,YAAY,QAAQ,OAAO,iBAAiB;;YAG5C,eAAe,eAAe;;qBAG7B;;qBAGA;;;wBASG,gBACd;EAAwB;wBACxB,SAAS,2BACR;;wBAuBa,mBAAmB,cAAc;;wBAqBjC,iBACd,sBACC;;wBAMa,aACd,qBACA,UAAS,kBACR;;wBAaa,cAAc,sBAAsB;;qBAUvC;qBACA;qBAIA;;wBAwBG,iBAAiB,cAAc;;qBAuBlC;;wBASG,iBAAiB,cAAc;;;wBAS/B,eACd,cACA,OAAO,UACP,iBAEE,aACA;EACG;EAAuB;;;wBAkBd,kBAAkB,eAAe;;wBAQjC,aACd,cACA,OAAO,UACP,eACA;YASU;;EAEV;IAAyB;;;EAEzB;;EAEA,eAAe;;EAEf;;EAEA,SAAS;;EAET;;;;wBAuFc,oBACd,gBACA,UAAU;;wBAuBI,iBACd,cACA,KAAK,qBACL;;;;wBAac,sBACd,uBAEE,aACA,SACA,cACA,WACA,QACA,mBACC,yBACF;;;;qBCnYU;iBAEI;;EAEf;;EAEA;;;EAGA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;wBAWc,iBAAiB,OAAO;wBAyCxB,0BAA0B;EACxC;EACA;EACA,UAAU;IACR;IACA;IACA;;EAEF;EACA;EACA;;;;;;;;wBAsBc,uBAAuB,oBAAoB;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/vite-plugins/project-brand.ts","../connect-utils/vite-plugins/app-shell.ts","../connect-utils/vite-plugins/build-hash.ts","../connect-utils/vite-plugins/connect-routes.ts","../connect-utils/vite-plugins/host-stylesheet.ts","../connect-utils/externalize-vendor.ts","../connect-utils/reactor-worker-build.ts","../connect-utils/worker-packages-build.ts","../connect-utils/types.ts","../connect-utils/helpers.ts","../connect-utils/runtime-config-schema.ts","../connect-utils/vite-config.ts","../connect-utils/vite-plugins/dynamic-base.ts","../connect-utils/vite-plugins/ph-config.ts","../connect-utils/vite-plugins/theme-boot.ts","../connect-utils/vite-plugins/vendor-import-map.ts"],"mappings":";;;;;;qBAAa;qBACA;qBACA;qBACA;;;KC4QD;;EAEV;;EAEA;EACA;;KAGU,gBAAgB;EAC1B,WAAW,YAAY;EACvB;;;;;qBCzQW;YAED;;EAEV;;EAEA;;;YAIU;YAEA,YAAY,QAAQ,OAAO,iBAAiB;;YAG5C,eAAe,eAAe;;qBAG7B;;qBAGA;;;wBASG,gBACd;EAAwB;wBACxB,SAAS,2BACR;;wBAuBa,mBAAmB,cAAc;;wBAqBjC,iBACd,sBACC;;wBAMa,aACd,qBACA,UAAS,kBACR;;wBAaa,cAAc,sBAAsB;;qBAUvC;qBACA;qBAIA;;wBAwBG,iBAAiB,cAAc;;qBAuBlC;;wBASG,iBAAiB,cAAc;;;wBAS/B,eACd,cACA,OAAO,UACP,iBAEE,aACA;EACG;EAAu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R;qBAAW;;;;;aAKnB,iDAAO;;;;;wBCDK,mBACd;EACE;EACA,WAAW;;WAMJ;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAMG;;aAEH;aACA;;;;WAMG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAMG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;wBA6DQ,yBAAyB,SAAS,kBAAe;;;;wBC5JjD,gBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuC7B,yBACd;EAAW;EAAqB;IAC/B;wBA4Da,gBAAgB;;;YClJpB;EACV,UAAU;EACV;EACA,UAAU;;EAEV,YAAY;;;;;;;EAOZ;;;;;;EAMA,qBAAqB;;;;;;EAMrB,WAAW;;;wBAuBG,aAAa,cAAc;KAYtC;EAAgB,SAAS;EAAwB;;;;wBAItC,eACd,SAAS,wBACR,OAAO;EAAiB,KAAK;;;;;;;;;qBC3EnB;;;;;;wBA4BG,0BAA0B;;;YCxB9B;;EAEV,SAAS;;wBA4BK,sBAAsB,SAAS,yBAAyB"}
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,6 @@ import { initSync, parse } from "es-module-lexer";
|
|
|
17
17
|
import { getConfig as getConfig$1 } from "@powerhousedao/config/node";
|
|
18
18
|
import tailwind from "@tailwindcss/vite";
|
|
19
19
|
import react from "@vitejs/plugin-react";
|
|
20
|
-
import { createHtmlPlugin } from "vite-plugin-html";
|
|
21
20
|
import { PwaConfigSchema } from "@powerhousedao/shared/document-model";
|
|
22
21
|
import { toCdnUrl } from "@powerhousedao/shared/registry/urls";
|
|
23
22
|
import { VitePWA } from "vite-plugin-pwa";
|
|
@@ -262,6 +261,15 @@ function ignoreBuildOutput(projectRoot) {
|
|
|
262
261
|
return path.startsWith(dist) || path.includes("/tauri-shell/target/") || path.includes("/src-tauri/target/");
|
|
263
262
|
};
|
|
264
263
|
}
|
|
264
|
+
/** Whether a watched path is in `routesDir` or is the folder itself. */
|
|
265
|
+
function inRoutesDir(projectRoot, routesDir) {
|
|
266
|
+
let watchedAs;
|
|
267
|
+
return (file) => {
|
|
268
|
+
watchedAs ??= [routesDir, join(realpathSync(projectRoot), relative(projectRoot, routesDir))];
|
|
269
|
+
const path = resolve(projectRoot, file);
|
|
270
|
+
return watchedAs.some((dir) => path === dir || path.startsWith(`${dir}${sep}`));
|
|
271
|
+
};
|
|
272
|
+
}
|
|
265
273
|
/** Connect's pathless sidebar layout; a project's routes in `_app/` render in it. */
|
|
266
274
|
const APP_LAYOUT = "_app";
|
|
267
275
|
function findRouteFile(dir, name) {
|
|
@@ -394,8 +402,10 @@ function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
|
|
|
394
402
|
const appLayout = findRouteFile(projectRoutes, APP_LAYOUT);
|
|
395
403
|
const appRoutes = join(projectRoutes, APP_LAYOUT);
|
|
396
404
|
const overridden = new Set([...overriddenConnectRoutes(join(routesDirectory, APP_LAYOUT), appRoutes)].map((file) => `${APP_LAYOUT}/${file}`));
|
|
397
|
-
return rootRoute("__root.tsx", [layout(APP_LAYOUT, appLayout ? fromRoutes(appLayout) : `${APP_LAYOUT}.tsx`, [...mountConnectRoutes(routesDirectory, APP_LAYOUT, overridden), ...existsSync(appRoutes) ? [physical("", fromRoutes(appRoutes))] : []]), physical("", fromRoutes(projectRoutes))]);
|
|
405
|
+
return rootRoute("__root.tsx", [layout(APP_LAYOUT, appLayout ? fromRoutes(appLayout) : `${APP_LAYOUT}.tsx`, [...mountConnectRoutes(routesDirectory, APP_LAYOUT, overridden), ...existsSync(appRoutes) ? [physical("", fromRoutes(appRoutes))] : []]), ...existsSync(projectRoutes) ? [physical("", fromRoutes(projectRoutes))] : []]);
|
|
398
406
|
};
|
|
407
|
+
const generatedRouteTree = connectRoutesTreeOf(projectRoot, projectRoutes);
|
|
408
|
+
const inProjectRoutes = inRoutesDir(projectRoot, projectRoutes);
|
|
399
409
|
const overrides = {
|
|
400
410
|
name: "ph-connect-route-overrides",
|
|
401
411
|
init: ({ generator }) => {
|
|
@@ -404,13 +414,15 @@ function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
|
|
|
404
414
|
configurable: true,
|
|
405
415
|
enumerable: true
|
|
406
416
|
});
|
|
417
|
+
importConnectRoutesByPackage(generator, generatedRouteTree);
|
|
418
|
+
followProjectRoutes(generator, inProjectRoutes);
|
|
407
419
|
}
|
|
408
420
|
};
|
|
409
421
|
const offers = isDefaultRoutesDir(projectRoot, projectRoutes);
|
|
410
422
|
return getConfig({
|
|
411
423
|
target: "react",
|
|
412
424
|
routesDirectory,
|
|
413
|
-
generatedRouteTree
|
|
425
|
+
generatedRouteTree,
|
|
414
426
|
virtualRouteConfig: virtualRouteConfig(),
|
|
415
427
|
plugins: offers ? [overrides, {
|
|
416
428
|
name: "ph-connect-offered-routes",
|
|
@@ -465,7 +477,6 @@ async function generateConnectRoutes(projectRoot, routesDir, config = connectRou
|
|
|
465
477
|
}).run();
|
|
466
478
|
assertNoSharedUrls(routeNodes);
|
|
467
479
|
assertNoDuplicateRoutes(config.generatedRouteTree);
|
|
468
|
-
importConnectRoutesByPackage(config.generatedRouteTree, config.routesDirectory);
|
|
469
480
|
const drops = dropsContext(projectRoot, routesDir, config.routesDirectory);
|
|
470
481
|
for (const node of routeNodes) {
|
|
471
482
|
const found = dropsOf(node, drops);
|
|
@@ -482,11 +493,23 @@ async function generateConnectRoutes(projectRoot, routesDir, config = connectRou
|
|
|
482
493
|
/** Connect's route files, as the generated tree imports them: by Connect's
|
|
483
494
|
* package name, which a project depends on. */
|
|
484
495
|
const CONNECT_ROUTES_SPECIFIER = "@powerhousedao/connect/routes";
|
|
485
|
-
function importConnectRoutesByPackage(
|
|
486
|
-
const
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
496
|
+
function importConnectRoutesByPackage(generator, treeFile) {
|
|
497
|
+
const writer = generator;
|
|
498
|
+
const write = writer.safeFileWrite.bind(writer);
|
|
499
|
+
writer.safeFileWrite = (opts) => {
|
|
500
|
+
if (resolve(opts.filePath) !== resolve(treeFile)) return write(opts);
|
|
501
|
+
const prefix = `"./${relative(dirname(treeFile), writer.config.routesDirectory).split(sep).join("/")}/`;
|
|
502
|
+
const newContent = opts.newContent.replace(new RegExp(`${escapeRegExp(prefix)}([^"]+)\\.js"`, "g"), `"${CONNECT_ROUTES_SPECIFIER}/$1"`);
|
|
503
|
+
return write({
|
|
504
|
+
...opts,
|
|
505
|
+
newContent
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function followProjectRoutes(generator, inProjectRoutes) {
|
|
510
|
+
const checker = generator;
|
|
511
|
+
const relevant = checker.isFileRelevantForRouteTreeGeneration.bind(checker);
|
|
512
|
+
checker.isFileRelevantForRouteTreeGeneration = (file) => relevant(file) || inProjectRoutes(file);
|
|
490
513
|
}
|
|
491
514
|
function assertNoDuplicateRoutes(treeFile) {
|
|
492
515
|
const tree = readFileSync(treeFile, "utf8");
|
|
@@ -565,13 +588,16 @@ function dropsPlugin(projectRoot, routesDir, routesDirectory) {
|
|
|
565
588
|
function escapeRegExp(text) {
|
|
566
589
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
567
590
|
}
|
|
568
|
-
/** Generates the tree when the project has routes
|
|
591
|
+
/** Generates the tree when the project has routes. Without them, a tree there
|
|
592
|
+
* is rewritten with Connect's routes only, never removed: Studio routes
|
|
593
|
+
* through it, and a removed folder's routes leave it, as tsc needs. */
|
|
569
594
|
async function syncConnectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectRoot)) {
|
|
570
|
-
if (routesDir)
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
rmSync(join(projectRoot, PACKAGE_ROUTES_MODULE), { force: true });
|
|
595
|
+
if (routesDir) {
|
|
596
|
+
await generateConnectRoutes(projectRoot, routesDir);
|
|
597
|
+
return;
|
|
574
598
|
}
|
|
599
|
+
rmSync(join(projectRoot, PACKAGE_ROUTES_MODULE), { force: true });
|
|
600
|
+
if (existsSync(join(projectRoot, ".ph/connect-routes.gen.ts"))) await generateConnectRoutes(projectRoot, join(projectRoot, HOST_ROUTES_DIR));
|
|
575
601
|
}
|
|
576
602
|
function connectDirOf(projectRoot) {
|
|
577
603
|
return dirname(resolvePackage("@powerhousedao/connect/package.json", projectRoot));
|
|
@@ -601,23 +627,21 @@ function connectRouteFileDeps(connectDir) {
|
|
|
601
627
|
return CONNECT_ROUTE_FILE_DEPS.map((dep) => `@powerhousedao/connect > ${dep}`);
|
|
602
628
|
}
|
|
603
629
|
/** Mounts a project's routes folder over Connect's routes; without one,
|
|
604
|
-
* Connect keeps its prebuilt tree and no router plugin runs.
|
|
630
|
+
* Connect keeps its prebuilt tree and no router plugin runs. Dev may pass a
|
|
631
|
+
* folder that does not exist yet: it is mounted once it does. */
|
|
605
632
|
function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectRoot)) {
|
|
606
633
|
const connectDir = connectDirOf(projectRoot);
|
|
607
634
|
const find = ROUTE_TREE_FIND;
|
|
608
635
|
const include = connectRouteFileDeps(connectDir);
|
|
609
|
-
if (!routesDir) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
include
|
|
619
|
-
};
|
|
620
|
-
}
|
|
636
|
+
if (!routesDir) return {
|
|
637
|
+
aliases: [{
|
|
638
|
+
find,
|
|
639
|
+
replacement: join(connectDir, "dist/route-tree.js")
|
|
640
|
+
}],
|
|
641
|
+
plugins: [],
|
|
642
|
+
dedupe: [],
|
|
643
|
+
include
|
|
644
|
+
};
|
|
621
645
|
const config = connectRoutesGeneratorConfig(connectDir, projectRoot, routesDir);
|
|
622
646
|
mkdirSync(dirname(config.generatedRouteTree), { recursive: true });
|
|
623
647
|
return {
|
|
@@ -628,17 +652,44 @@ function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectR
|
|
|
628
652
|
find: /^@powerhousedao\/connect\/route-views$/,
|
|
629
653
|
replacement: join(connectDir, "dist/route-views.js")
|
|
630
654
|
}],
|
|
631
|
-
plugins: [
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
655
|
+
plugins: [
|
|
656
|
+
{
|
|
657
|
+
name: "ph-connect-routes-check",
|
|
658
|
+
buildStart: () => generateConnectRoutes(projectRoot, routesDir, config)
|
|
659
|
+
},
|
|
660
|
+
tanstackRouter({
|
|
661
|
+
...config,
|
|
662
|
+
plugins: [...config.plugins ?? [], dropsPlugin(projectRoot, routesDir, config.routesDirectory)]
|
|
663
|
+
}),
|
|
664
|
+
connectRoutesWatcher(projectRoot, routesDir, config)
|
|
665
|
+
],
|
|
638
666
|
dedupe: ["@tanstack/react-router"],
|
|
639
667
|
include
|
|
640
668
|
};
|
|
641
669
|
}
|
|
670
|
+
/** Dev: rewrites the tree as files and folders under the routes folder come and
|
|
671
|
+
* go, the folder itself included; the router plugin follows the tree. */
|
|
672
|
+
function connectRoutesWatcher(projectRoot, routesDir, config) {
|
|
673
|
+
const inRoutes = inRoutesDir(projectRoot, routesDir);
|
|
674
|
+
return {
|
|
675
|
+
name: "ph-connect-routes-watcher",
|
|
676
|
+
apply: "serve",
|
|
677
|
+
configureServer(server) {
|
|
678
|
+
const { logger } = server.config;
|
|
679
|
+
let queue = Promise.resolve();
|
|
680
|
+
const onEvent = (file) => {
|
|
681
|
+
if (!inRoutes(file)) return;
|
|
682
|
+
queue = queue.then(() => generateConnectRoutes(projectRoot, routesDir, config)).catch((error) => logger.error(`[connect] ${error.message}`));
|
|
683
|
+
};
|
|
684
|
+
for (const event of [
|
|
685
|
+
"add",
|
|
686
|
+
"unlink",
|
|
687
|
+
"addDir",
|
|
688
|
+
"unlinkDir"
|
|
689
|
+
]) server.watcher.on(event, onEvent);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
}
|
|
642
693
|
const ROUTER_PACKAGES = /[\\/]node_modules[\\/]@tanstack[\\/](react-router|router-core|history|react-store|store)[\\/]/;
|
|
643
694
|
/** One chunk for the router and the project's route configs, which the split
|
|
644
695
|
* route components would otherwise spread over several shared chunks. */
|
|
@@ -3851,6 +3902,14 @@ const BASE_PRECACHE = {
|
|
|
3851
3902
|
"**/*.gz"
|
|
3852
3903
|
]
|
|
3853
3904
|
};
|
|
3905
|
+
/** The files under `dir` (a project's public/), by path relative to it. */
|
|
3906
|
+
function staticFilesIn(dir) {
|
|
3907
|
+
if (!existsSync(dir)) return [];
|
|
3908
|
+
return readdirSync(dir, {
|
|
3909
|
+
recursive: true,
|
|
3910
|
+
withFileTypes: true
|
|
3911
|
+
}).filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name).slice(dir.length + 1).replaceAll("\\", "/"));
|
|
3912
|
+
}
|
|
3854
3913
|
const SW_FILENAME = "service-worker.ts";
|
|
3855
3914
|
/**
|
|
3856
3915
|
* Absolute directory holding the hand-written service-worker source. Resolved
|
|
@@ -3906,7 +3965,7 @@ function phSwConfigPlugin(data) {
|
|
|
3906
3965
|
* clears its caches on the browser's next service-worker update check.
|
|
3907
3966
|
*/
|
|
3908
3967
|
function connectPwaPlugins(options) {
|
|
3909
|
-
const { offlineEnabled, pwa, brand } = options;
|
|
3968
|
+
const { offlineEnabled, pwa, brand, staticFiles = [] } = options;
|
|
3910
3969
|
if (!offlineEnabled) return [VitePWA({
|
|
3911
3970
|
selfDestroying: true,
|
|
3912
3971
|
strategies: "generateSW",
|
|
@@ -3921,7 +3980,8 @@ function connectPwaPlugins(options) {
|
|
|
3921
3980
|
const swConfig = {
|
|
3922
3981
|
EMBEDDED_BASE_MANIFEST: manifest,
|
|
3923
3982
|
EXTRA_RUNTIME_CACHING: pwa?.runtimeCaching ?? [],
|
|
3924
|
-
NAVIGATE_FALLBACK_DENYLIST_EXTRA: pwa?.navigateFallbackDenylist ?? []
|
|
3983
|
+
NAVIGATE_FALLBACK_DENYLIST_EXTRA: pwa?.navigateFallbackDenylist ?? [],
|
|
3984
|
+
STATIC_FILES: staticFiles
|
|
3925
3985
|
};
|
|
3926
3986
|
return [connectPwaIconsPlugin(), VitePWA({
|
|
3927
3987
|
strategies: "injectManifest",
|
|
@@ -4478,10 +4538,13 @@ function getConnectBaseViteConfig(options) {
|
|
|
4478
4538
|
const plugins = [
|
|
4479
4539
|
tailwind(),
|
|
4480
4540
|
react(),
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4541
|
+
{
|
|
4542
|
+
name: "ph-connect-html-tags",
|
|
4543
|
+
transformIndexHtml: {
|
|
4544
|
+
order: "pre",
|
|
4545
|
+
handler: () => [...connectHtmlTags, ...devImportmapTag]
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4485
4548
|
];
|
|
4486
4549
|
if (uploadSentrySourcemaps) plugins.push(import("@sentry/vite-plugin").then(({ sentryVitePlugin }) => sentryVitePlugin({
|
|
4487
4550
|
release: {
|
|
@@ -4535,7 +4598,8 @@ function getConnectBaseViteConfig(options) {
|
|
|
4535
4598
|
return connectPwaPlugins({
|
|
4536
4599
|
offlineEnabled,
|
|
4537
4600
|
pwa: mergedPwa,
|
|
4538
|
-
brand: projectBrand
|
|
4601
|
+
brand: projectBrand,
|
|
4602
|
+
staticFiles: staticFilesIn(join(options.dirname, "public"))
|
|
4539
4603
|
});
|
|
4540
4604
|
})();
|
|
4541
4605
|
const reactExternal = [
|
|
@@ -4556,7 +4620,8 @@ function getConnectBaseViteConfig(options) {
|
|
|
4556
4620
|
}
|
|
4557
4621
|
}).filter((p) => p !== null);
|
|
4558
4622
|
const routesDir = resolveConnectRoutesDir(options.dirname, options.routes) ?? false;
|
|
4559
|
-
const
|
|
4623
|
+
const mountedRoutesDir = routesDir || (mode === "development" && options.routes === void 0 ? join(options.dirname, "hosts/connect/routes") : false);
|
|
4624
|
+
const routes = connectRoutes(options.dirname, mountedRoutesDir);
|
|
4560
4625
|
const customShell = hasProjectAppLayout(routesDir || void 0);
|
|
4561
4626
|
const hostStylesheet = hostStylesheetPath(options.dirname, routesDir);
|
|
4562
4627
|
return {
|
|
@@ -4568,7 +4633,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
4568
4633
|
watch: { ignored: [
|
|
4569
4634
|
"**/backup-documents/**",
|
|
4570
4635
|
"**/coverage/**",
|
|
4571
|
-
ignoreDotPhButRouteTree(options.dirname,
|
|
4636
|
+
ignoreDotPhButRouteTree(options.dirname, mountedRoutesDir),
|
|
4572
4637
|
ignoreBuildOutput(options.dirname)
|
|
4573
4638
|
] },
|
|
4574
4639
|
fs: { allow: [searchForWorkspaceRoot(options.dirname), ...linkedRoots] }
|
|
@@ -4590,7 +4655,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
4590
4655
|
},
|
|
4591
4656
|
customLogger,
|
|
4592
4657
|
envPrefix: ["PH_CONNECT_"],
|
|
4593
|
-
optimizeDeps: connectOptimizeDeps(options.dirname,
|
|
4658
|
+
optimizeDeps: connectOptimizeDeps(options.dirname, mountedRoutesDir, routes.include),
|
|
4594
4659
|
plugins: [
|
|
4595
4660
|
configPlugin,
|
|
4596
4661
|
hostStylesheetPlugin(options.dirname, hostStylesheet),
|
|
@@ -4598,7 +4663,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
4598
4663
|
packages: localPackagesFromConfig,
|
|
4599
4664
|
projectRoot: options.dirname
|
|
4600
4665
|
}),
|
|
4601
|
-
devReactImportmapPlugin(options.dirname,
|
|
4666
|
+
devReactImportmapPlugin(options.dirname, mountedRoutesDir),
|
|
4602
4667
|
reactorWorkerDevPlugin(options.dirname),
|
|
4603
4668
|
...routes.plugins,
|
|
4604
4669
|
...plugins,
|
|
@@ -4642,6 +4707,6 @@ function getConnectBaseViteConfig(options) {
|
|
|
4642
4707
|
};
|
|
4643
4708
|
}
|
|
4644
4709
|
//#endregion
|
|
4645
|
-
export { APP_LAYOUT, APP_SHELLS_FILE, APP_SHELL_MARKER, BOOT_RECOVER_KEY, BOOT_RECOVER_MARKER, BOOT_RECOVER_SCRIPT, BUILDER_TOOLS_VERSION, BUILD_HASH_FILE, CONNECT_ROUTES_GEN, CONNECT_ROUTES_SPECIFIER, CONNECT_ROUTE_FILE_DEPS, CORE_ROUTE_TREE_SPECIFIER, DEFAULT_APP_NAME, DEFAULT_CONNECT_OUTDIR, DEFAULT_VENDOR_INCLUDE, DYNAMIC_BASE_PLACEHOLDER, EXTERNAL_PACKAGES_IMPORT, HOST_ROUTES_DIR, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, LOCK_STALE_MS, PACKAGE_ROUTES_MODULE, PH_DIR_NAME, REACTOR_WORKER_ENTRY, REACTOR_WORKER_MIME, REACTOR_WORKER_URL_PREFIX, ROUTE_TREE_SPECIFIER, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, SHELL_PLUGINS_FILE, THEME_BOOT_MARKER, VENDOR_EXTERNAL, VENDOR_SKIP_SUBPATHS, VENDOR_URL_PREFIX, WORKER_PACKAGES_MANIFEST, acquireLock, appShellVariant, appShellVariantOf, appendToHtmlHead, backupIndexHtml, buildHashFromBuildOptions, computeBuildHash, computeSourceDigest, connectAppShellPlugin, connectBuildHashPlugin, connectDynamicBasePlugin, connectRouteFileDeps, connectRouterChunkGroups, connectRoutes, connectRoutesDirOf, connectRoutesGeneratorConfig, connectRoutesTreeOf, connectThemeBootPlugin, copyConnect, directoryContentDigest, distDirFingerprint, ensureNodeVersion, escapeForRegExp, findBundleSpecifierOffenders, findDisallowedSpecifiers, findPackageRoot, findWorkerUnsafeMarkers, generateConnectRoutes, getConnectBaseViteConfig, getConnectHtmlTags, hasProjectAppLayout, hostStylesheetPath, hostStylesheetPlugin, ignoreBuildOutput, ignoreDotPhButRouteTree, injectAppShell, linkedBuildStamp, makeImportScriptFromPackages, missingVendorEntries, overriddenConnectRoutes, ownProjectPackage, phConfigPlugin, prebuildConnectVendor, prebuildReactorWorker, prebuildWorkerPackages, prependToHtmlHead, publishDirAtomic, readAppShell, readAppShells, readJsonFile, readShellPlugins, readShellPluginsIn, rebaseShellLinks, relativeCssUrls, releaseLock, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolveConnectRoutesDir, resolveOwnDeps, resolveOwnPackageVersion, resolvePackage, resolveReactorWorkerSource, resolveVersionDigest, resolveViteConfigPath, resolveWorkspacePackageDir, routeIdOf, runShellScriptPlugin, runTsc, runWorkerBuildEntries, runtimeConfigSchema, stripVersionFromPackage, swapAppShell, syncConnectRoutes, upstreamWorkerPackages, vendorImportMapPlugin, vendorRelativePath, withAppTitle, withErrorOverlay, withHostStylesheet, withShellAppName, withSourceLocations, withVendorBase, workerSafeVendorImports };
|
|
4710
|
+
export { APP_LAYOUT, APP_SHELLS_FILE, APP_SHELL_MARKER, BOOT_RECOVER_KEY, BOOT_RECOVER_MARKER, BOOT_RECOVER_SCRIPT, BUILDER_TOOLS_VERSION, BUILD_HASH_FILE, CONNECT_ROUTES_GEN, CONNECT_ROUTES_SPECIFIER, CONNECT_ROUTE_FILE_DEPS, CORE_ROUTE_TREE_SPECIFIER, DEFAULT_APP_NAME, DEFAULT_CONNECT_OUTDIR, DEFAULT_VENDOR_INCLUDE, DYNAMIC_BASE_PLACEHOLDER, EXTERNAL_PACKAGES_IMPORT, HOST_ROUTES_DIR, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, LOCK_STALE_MS, PACKAGE_ROUTES_MODULE, PH_DIR_NAME, REACTOR_WORKER_ENTRY, REACTOR_WORKER_MIME, REACTOR_WORKER_URL_PREFIX, ROUTE_TREE_SPECIFIER, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, SHELL_PLUGINS_FILE, THEME_BOOT_MARKER, VENDOR_EXTERNAL, VENDOR_SKIP_SUBPATHS, VENDOR_URL_PREFIX, WORKER_PACKAGES_MANIFEST, acquireLock, appShellVariant, appShellVariantOf, appendToHtmlHead, backupIndexHtml, buildHashFromBuildOptions, computeBuildHash, computeSourceDigest, connectAppShellPlugin, connectBuildHashPlugin, connectDynamicBasePlugin, connectRouteFileDeps, connectRouterChunkGroups, connectRoutes, connectRoutesDirOf, connectRoutesGeneratorConfig, connectRoutesTreeOf, connectRoutesWatcher, connectThemeBootPlugin, copyConnect, directoryContentDigest, distDirFingerprint, ensureNodeVersion, escapeForRegExp, findBundleSpecifierOffenders, findDisallowedSpecifiers, findPackageRoot, findWorkerUnsafeMarkers, generateConnectRoutes, getConnectBaseViteConfig, getConnectHtmlTags, hasProjectAppLayout, hostStylesheetPath, hostStylesheetPlugin, ignoreBuildOutput, ignoreDotPhButRouteTree, injectAppShell, linkedBuildStamp, makeImportScriptFromPackages, missingVendorEntries, overriddenConnectRoutes, ownProjectPackage, phConfigPlugin, prebuildConnectVendor, prebuildReactorWorker, prebuildWorkerPackages, prependToHtmlHead, publishDirAtomic, readAppShell, readAppShells, readJsonFile, readShellPlugins, readShellPluginsIn, rebaseShellLinks, relativeCssUrls, releaseLock, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolveConnectRoutesDir, resolveOwnDeps, resolveOwnPackageVersion, resolvePackage, resolveReactorWorkerSource, resolveVersionDigest, resolveViteConfigPath, resolveWorkspacePackageDir, routeIdOf, runShellScriptPlugin, runTsc, runWorkerBuildEntries, runtimeConfigSchema, stripVersionFromPackage, swapAppShell, syncConnectRoutes, upstreamWorkerPackages, vendorImportMapPlugin, vendorRelativePath, withAppTitle, withErrorOverlay, withHostStylesheet, withShellAppName, withSourceLocations, withVendorBase, workerSafeVendorImports };
|
|
4646
4711
|
|
|
4647
4712
|
//# sourceMappingURL=index.mjs.map
|