Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions vuu-ui/packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# @vuu-ui/core portal
# @vuu-ui/core

Reusable VUU portal host and Module Federation integration components.
Core VUU authentication and data-context APIs are exported from
`@vuu-ui/core` and can be registered as a shared Module Federation dependency.

See [DESIGN.md](./DESIGN.md) for the package design.
Portal host and remote-module APIs are exported separately from
`@vuu-ui/core/portal` so portal dependencies are not included in the shared
module.

See [the portal design](./docs/portal-design.md) for details.
5 changes: 3 additions & 2 deletions vuu-ui/packages/core/docs/portal-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Purpose

`@vuu-ui/core` provides the reusable components, types, and utilities
`@vuu-ui/core/portal` provides the reusable components, types, and utilities
needed to build VUU portals with Module Federation. It is the package boundary
for portal host behavior and remote-module integration.

Expand Down Expand Up @@ -45,8 +45,9 @@ core/
| |-- portal-shell/
| |-- remote-module/
| |-- index.ts
| |-- portal.ts
| `-- RemoteModuleDescriptor.ts
|-- DESIGN.md
|-- docs/
|-- README.md
|-- package.json
`-- tsconfig.json
Expand Down
4 changes: 4 additions & 0 deletions vuu-ui/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"docs"
],
"main": "src/index.ts",
"exports": {
".": "./src/index.ts",
"./portal": "./src/portal.ts"
},
"author": "heswell",
"license": "Apache-2.0",
"type": "module",
Expand Down
11 changes: 0 additions & 11 deletions vuu-ui/packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,3 @@ export {
DataProvider,
useData,
} from "./context-definitions/DataProvider";
export {
PortalHeader,
type PortalHeaderProps,
} from "./portal-header/PortalHeader";
export { PortalNav, type PortalNavProps } from "./portal-nav/PortalNav";
export { PortalShell, type PortalShellProps } from "./portal-shell/PortalShell";
export {
RemoteModule,
type RemoteModuleProps,
} from "./remote-module/RemoteModule";
export type { RemoteModuleDescriptor } from "./RemoteModuleDescriptor";
2 changes: 1 addition & 1 deletion vuu-ui/packages/core/src/portal-header/PortalHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Toolbar, ToolbarContent, Tooltray } from "@salt-ds/core";
import { useLogout } from "../auth";
import { useLogout } from "@vuu-ui/core";
import cx from "clsx";
import type { HTMLAttributes } from "react";

Expand Down
11 changes: 11 additions & 0 deletions vuu-ui/packages/core/src/portal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export {
PortalHeader,
type PortalHeaderProps,
} from "./portal-header/PortalHeader";
export { PortalNav, type PortalNavProps } from "./portal-nav/PortalNav";
export { PortalShell, type PortalShellProps } from "./portal-shell/PortalShell";
export {
RemoteModule,
type RemoteModuleProps,
} from "./remote-module/RemoteModule";
export type { RemoteModuleDescriptor } from "./RemoteModuleDescriptor";
5 changes: 4 additions & 1 deletion vuu-ui/packages/core/src/remote-module/RemoteModule.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { AuthenticationProvider, type RemoteModuleConnection } from "../auth";
import {
AuthenticationProvider,
type RemoteModuleConnection,
} from "@vuu-ui/core";
import {
loadRemote,
registerRemotes,
Expand Down
4 changes: 2 additions & 2 deletions vuu-ui/packages/vuu-shell/src/feature/Feature.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RemoteModule } from "@vuu-ui/core";
import { RemoteModule } from "@vuu-ui/core/portal";
import { registerComponent } from "@vuu-ui/vuu-utils";

/** @deprecated Use RemoteModule from @vuu-ui/core. */
/** @deprecated Use RemoteModule from @vuu-ui/core/portal. */
export const Feature = RemoteModule;
Feature.displayName = "Feature";
registerComponent("Feature", Feature, "view");
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-shell/src/feature/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from "./Feature";
export {
RemoteModule,
type RemoteModuleProps,
} from "@vuu-ui/core";
} from "@vuu-ui/core/portal";
2 changes: 1 addition & 1 deletion vuu-ui/sample-apps/vuu-portal/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { registerComponent } from "@vuu-ui/vuu-utils";
import { useEffect, useState } from "react";
import { ConfirmSelectionPanel } from "./order-management/cancel-confirm-prompt/ConfirmSelectionPanel";
import { BrowserRouter } from "react-router-dom";
import { PortalShell, type RemoteModuleDescriptor } from "@vuu-ui/core";
import { PortalShell, type RemoteModuleDescriptor } from "@vuu-ui/core/portal";
import { getRegisteredModules } from "@vuu-ui/vuu-shell";

import "./App.css";
Expand Down
22 changes: 11 additions & 11 deletions vuu-ui/scripts/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@ import fs from "fs";

export const readPackageJson = (path = "package.json") => readJson(path);

type PackageExports = {
".": {
import: string;
};
style?: {
import: string;
};
};
type PackageExport = string | { import: string };
type PackageExports = Record<string, PackageExport>;
type Json = {
exports?: PackageExports;
files?: string[];
Expand All @@ -32,6 +26,7 @@ export async function writePackageJSON(
): Promise<void> {
return new Promise((resolve, reject) => {
const {
exports: sourceExports,
files: filesFromPackageJson = [],
name: scopedPackageName,
style,
Expand All @@ -49,9 +44,14 @@ export async function writePackageJSON(
});
});

const exports: PackageExports = {
".": { import: "./src/index.js" },
};
const exports: PackageExports = Object.fromEntries(
Object.entries(
sourceExports ?? { ".": "./src/index.ts" },
).map(([subpath, target]) => {
const importPath = typeof target === "string" ? target : target.import;
return [subpath, { import: importPath.replace(/\.tsx?$/, ".js") }];
}),
);

if (style) {
exports.style = { import: style };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
PortalNav,
type RemoteModuleDescriptor,
} from "@vuu-ui/core";
} from "@vuu-ui/core/portal";

const remoteModule = (path: string): RemoteModuleDescriptor => {
const name = path.split("/").filter(Boolean).at(-1) ?? path;
Expand Down
Loading