@rise-x/apps-sdk 0.9.0 → 0.11.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/README.md +117 -32
- package/build/rsbuild/index.d.ts +6 -1
- package/build/rsbuild/index.js +24 -3
- package/build/ui/classes.json +209 -0
- package/build/ui/components/ai.d.ts +33 -1
- package/build/ui/components/app-frame.d.ts +16 -10
- package/build/ui/components/chat-input.d.ts +28 -0
- package/build/ui/components/message-scroller.d.ts +34 -10
- package/build/ui/components/sheet.d.ts +10 -0
- package/build/ui/components/thinking-rings.d.ts +4 -0
- package/build/ui/demo.html +26794 -0
- package/build/ui/index.d.ts +2 -0
- package/build/ui/standalone.js +60 -58
- package/build/ui/styles.css +1 -1
- package/package.json +4 -3
- package/template/AGENTS.md +3 -3
- package/template/README.md +5 -5
- package/template/package.json +8 -9
- package/template/rsbuild.config.mts +17 -0
- package/template/src/App.tsx +4 -1
- package/template/tsconfig.json +3 -1
- package/build/ui/reference/README.md +0 -11
- package/build/ui/reference/components/accordion.tsx +0 -85
- package/build/ui/reference/components/ai.tsx +0 -293
- package/build/ui/reference/components/alert-dialog.tsx +0 -207
- package/build/ui/reference/components/alert.tsx +0 -112
- package/build/ui/reference/components/app-frame.tsx +0 -71
- package/build/ui/reference/components/aspect-ratio.tsx +0 -28
- package/build/ui/reference/components/avatar.tsx +0 -158
- package/build/ui/reference/components/badge.tsx +0 -160
- package/build/ui/reference/components/button-group.tsx +0 -77
- package/build/ui/reference/components/button.tsx +0 -109
- package/build/ui/reference/components/calendar.tsx +0 -119
- package/build/ui/reference/components/card.tsx +0 -144
- package/build/ui/reference/components/carousel.tsx +0 -248
- package/build/ui/reference/components/chart.tsx +0 -704
- package/build/ui/reference/components/checkbox.tsx +0 -44
- package/build/ui/reference/components/collapsible.tsx +0 -43
- package/build/ui/reference/components/combobox.tsx +0 -146
- package/build/ui/reference/components/command.tsx +0 -181
- package/build/ui/reference/components/context-menu.tsx +0 -243
- package/build/ui/reference/components/data-table.tsx +0 -650
- package/build/ui/reference/components/date-picker.tsx +0 -218
- package/build/ui/reference/components/dialog.tsx +0 -172
- package/build/ui/reference/components/direction.tsx +0 -22
- package/build/ui/reference/components/dropdown-menu.tsx +0 -245
- package/build/ui/reference/components/empty-state.tsx +0 -63
- package/build/ui/reference/components/field.tsx +0 -252
- package/build/ui/reference/components/file-upload.tsx +0 -116
- package/build/ui/reference/components/hover-card.tsx +0 -64
- package/build/ui/reference/components/input-group.tsx +0 -157
- package/build/ui/reference/components/input-otp.tsx +0 -106
- package/build/ui/reference/components/input.tsx +0 -86
- package/build/ui/reference/components/item.tsx +0 -188
- package/build/ui/reference/components/kbd.tsx +0 -43
- package/build/ui/reference/components/label.tsx +0 -19
- package/build/ui/reference/components/list.tsx +0 -191
- package/build/ui/reference/components/map.css +0 -251
- package/build/ui/reference/components/map.tsx +0 -294
- package/build/ui/reference/components/menubar.tsx +0 -275
- package/build/ui/reference/components/message-scroller.tsx +0 -141
- package/build/ui/reference/components/message.tsx +0 -177
- package/build/ui/reference/components/nav.tsx +0 -127
- package/build/ui/reference/components/navigation-menu.tsx +0 -191
- package/build/ui/reference/components/page-header.tsx +0 -245
- package/build/ui/reference/components/popover.tsx +0 -76
- package/build/ui/reference/components/progress.tsx +0 -31
- package/build/ui/reference/components/radio.tsx +0 -65
- package/build/ui/reference/components/resizable.tsx +0 -40
- package/build/ui/reference/components/scroll-area.tsx +0 -55
- package/build/ui/reference/components/segmented.tsx +0 -45
- package/build/ui/reference/components/select.tsx +0 -188
- package/build/ui/reference/components/separator.tsx +0 -26
- package/build/ui/reference/components/sheet.tsx +0 -184
- package/build/ui/reference/components/skeleton.tsx +0 -15
- package/build/ui/reference/components/slider.tsx +0 -161
- package/build/ui/reference/components/snackbar.tsx +0 -27
- package/build/ui/reference/components/sonner.tsx +0 -43
- package/build/ui/reference/components/spinner.tsx +0 -27
- package/build/ui/reference/components/statistic.tsx +0 -122
- package/build/ui/reference/components/stepper.tsx +0 -138
- package/build/ui/reference/components/switch.tsx +0 -47
- package/build/ui/reference/components/table.tsx +0 -246
- package/build/ui/reference/components/textarea.tsx +0 -28
- package/build/ui/reference/components/timeline.tsx +0 -101
- package/build/ui/reference/components/toggle-group.tsx +0 -86
- package/build/ui/reference/components/toggle.tsx +0 -46
- package/build/ui/reference/components/tooltip.tsx +0 -53
- package/build/ui/reference/index.ts +0 -69
- package/build/ui/reference/lib/utils.ts +0 -34
- package/template/webpack.config.js +0 -112
- package/template/webpack.local.config.js +0 -68
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ pnpm start
|
|
|
22
22
|
| Flag | Default | Meaning |
|
|
23
23
|
| --- | --- | --- |
|
|
24
24
|
| `--pm=<npm\|yarn\|pnpm>` | auto-detected | package manager used for `install` |
|
|
25
|
-
| `--port=<n>` | `5101` |
|
|
25
|
+
| `--port=<n>` | `5101` | dev-server port in the generated app |
|
|
26
26
|
| `--skip-install` | off | skip `<pm> install` after scaffolding |
|
|
27
27
|
| `--json` | off | emit `{ path, slug, scope, pkgName, port, pm }` on stdout |
|
|
28
28
|
|
|
@@ -32,13 +32,49 @@ The package ships what an agent needs to build **static single-file HTML
|
|
|
32
32
|
design mocks** without repo access:
|
|
33
33
|
|
|
34
34
|
- `build/ui/styles.css` — the compiled design-system stylesheet, **Inter font
|
|
35
|
-
embedded** — inline it into the mock.
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
embedded**, **Tailwind preflight included** — inline it into the mock. The
|
|
36
|
+
preflight matters: a standalone HTML file has no host to establish
|
|
37
|
+
`box-sizing: border-box`, and without it every `w-full` control with
|
|
38
|
+
horizontal padding renders wider than its container.
|
|
39
|
+
- `build/ui/demo.html` — the Shell design-system demo page, pre-rendered to
|
|
40
|
+
static HTML: ground-truth markup for every component, generated at build
|
|
41
|
+
time from `Shell/src/components/__demo__`. Fully self-contained — it inlines
|
|
42
|
+
`styles.css` above, the same file you inline into your mock, so markup
|
|
43
|
+
copied out of the demo renders in your mock exactly as it renders there.
|
|
44
|
+
Utilities you invent for the mock's own scaffolding are a different matter:
|
|
45
|
+
only classes used by the design system or by the demo page have rules, so
|
|
46
|
+
write mock layout as plain CSS. Specimens styled by CSS outside the design
|
|
47
|
+
system (the map's leaflet sheet, the Ask Diana animations) render unstyled
|
|
48
|
+
in the demo and in mocks.
|
|
49
|
+
- `build/ui/classes.json` — the exact class string for every variant of every
|
|
50
|
+
variant-bearing component, generated from the components' own cva functions
|
|
51
|
+
and merged the way the component merges them. Use it for a combination the
|
|
52
|
+
demo doesn't happen to render (a `default` button at size `sm`) instead of
|
|
53
|
+
splicing fragments from two specimens. Each entry names its `dimensions`, and
|
|
54
|
+
keys join their values in that order: `button.classes["default|sm"]`. Entries
|
|
55
|
+
are named after the cva function, not the file it lives in — `trend` and
|
|
56
|
+
`confidence`, not `statistic` and `ai`.
|
|
38
57
|
- `template/src/App.tsx` — the canonical app layout (left-rail chrome +
|
|
39
58
|
screens); scaffolded apps start from it, and design mocks follow the same
|
|
40
59
|
composition.
|
|
41
60
|
|
|
61
|
+
### Navigating demo.html (for agents)
|
|
62
|
+
|
|
63
|
+
The file is pretty-printed and starts with a navigation guide plus a JSON
|
|
64
|
+
table of contents (`<script type="application/json" id="demo-toc">`) listing
|
|
65
|
+
every section, screen, and the `data-slot` components each section
|
|
66
|
+
demonstrates. Read the first ~80 lines for the TOC, then grep:
|
|
67
|
+
|
|
68
|
+
| To find | Grep for |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| a section (component family / pattern) | `data-section="<id>"` |
|
|
71
|
+
| a full screen (app layout, AI chat, dashboard, ...) | `data-screen-panel="<id>"` |
|
|
72
|
+
| one component's real markup | `data-slot="<name>"` |
|
|
73
|
+
|
|
74
|
+
Component props and variants live in the shipped types —
|
|
75
|
+
`build/ui/components/<name>.d.ts`, named to match the `data-slot` prefixes
|
|
76
|
+
(in the rise-x-app monorepo, the sources are `packages/ui/src/components/`).
|
|
77
|
+
|
|
42
78
|
## Use in app code
|
|
43
79
|
|
|
44
80
|
```ts
|
|
@@ -70,7 +106,7 @@ import { Button, Dialog, DialogContent, Input, cn } from '@rise-x/apps-sdk/ui';
|
|
|
70
106
|
The root layout contract, scaffolded into every new app:
|
|
71
107
|
|
|
72
108
|
```tsx
|
|
73
|
-
<AppFrame>
|
|
109
|
+
<AppFrame mobileNav="tabs">
|
|
74
110
|
<AppRail>{/* Nav / NavItem rail */}</AppRail>
|
|
75
111
|
<AppContent>{/* screens; the app's ONE scroll container */}</AppContent>
|
|
76
112
|
</AppFrame>
|
|
@@ -85,10 +121,30 @@ Both pad with `var(--topbar-h, 0px)`, so in hosts without a floating bar
|
|
|
85
121
|
rail-plus-content layout. Never hardcode a bar height and never add a second
|
|
86
122
|
page-level scroller.
|
|
87
123
|
|
|
88
|
-
The frame is responsive by default
|
|
89
|
-
`
|
|
90
|
-
(
|
|
91
|
-
|
|
124
|
+
The frame is responsive by default, and it measures **itself**, not the window:
|
|
125
|
+
`AppFrame` is a CSS container, so the layout answers to the region the app was
|
|
126
|
+
given (the shell's chrome takes space the app never gets). Below the frame's
|
|
127
|
+
`2xl` container width (672px) it stacks and `NavSection` headers hide.
|
|
128
|
+
|
|
129
|
+
Being a container also makes the frame the containing block for `position:
|
|
130
|
+
fixed` descendants, in every mode: a fixed action bar or FAB you render inside
|
|
131
|
+
`AppFrame` pins to the app's region, not to the browser window. That is
|
|
132
|
+
usually what you want. For something that genuinely belongs to the window,
|
|
133
|
+
portal it to `document.body` the way the kit's `Dialog`, `Sheet` and `Popover`
|
|
134
|
+
already do.
|
|
135
|
+
|
|
136
|
+
`mobileNav` picks what the rail becomes at that width:
|
|
137
|
+
|
|
138
|
+
| Value | Narrow rail |
|
|
139
|
+
| --- | --- |
|
|
140
|
+
| `"strip"` (default) | A horizontal, scrollable nav strip under the top bar. |
|
|
141
|
+
| `"tabs"` | A bottom tab bar, the native phone pattern — icon over label, one equal share each, safe-area padding. The scaffold sets this. |
|
|
142
|
+
|
|
143
|
+
In `tabs` mode an app with **more than five** nav items shows the first four and
|
|
144
|
+
a **More** tab that opens the rest in a bottom sheet; the wide rail still lists
|
|
145
|
+
everything. Pass `moreLabel` on `AppRail` to localise the label. Don't hand-roll
|
|
146
|
+
a tab bar, and don't write your own breakpoints around the frame; compose inside
|
|
147
|
+
it.
|
|
92
148
|
|
|
93
149
|
Rendering an `AppFrame` anywhere in the app is the signal that the app owns
|
|
94
150
|
its layout: the next-gen shell detects it and hands over the full-bleed
|
|
@@ -103,14 +159,14 @@ correctly, and there is never a second React/component instance.
|
|
|
103
159
|
|
|
104
160
|
Requirements in the app:
|
|
105
161
|
|
|
106
|
-
1.
|
|
162
|
+
1. It must be a Module Federation share. The preset does this for you:
|
|
107
163
|
|
|
108
164
|
```js
|
|
109
165
|
'@rise-x/ui': { singleton: true, requiredVersion: false, import: false },
|
|
110
166
|
```
|
|
111
167
|
|
|
112
|
-
2. Federated, components render from the shell's copy. The standalone
|
|
113
|
-
|
|
168
|
+
2. Federated, components render from the shell's copy. The preset's standalone
|
|
169
|
+
branch aliases `@rise-x/ui` to the SDK's own
|
|
114
170
|
compiled bundle (`./ui/standalone`) instead — a self-contained snapshot
|
|
115
171
|
with its CSS self-injected, so components render for real with no shell.
|
|
116
172
|
It's a snapshot, not the source of truth: verify in a host (or deployed)
|
|
@@ -162,7 +218,7 @@ cards and list rows, and children render over the map as overlays.
|
|
|
162
218
|
|
|
163
219
|
### Lifecycle hooks
|
|
164
220
|
|
|
165
|
-
Expose a `./lifecycle` module
|
|
221
|
+
Expose a `./lifecycle` module — the preset exposes it by default — and export any subset of the three hooks:
|
|
166
222
|
|
|
167
223
|
```ts
|
|
168
224
|
// src/lifecycle.ts
|
|
@@ -183,15 +239,12 @@ export const onUninstall: UninstallHook = async ({ manifest }) => {
|
|
|
183
239
|
};
|
|
184
240
|
```
|
|
185
241
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
// ...
|
|
194
|
-
});
|
|
242
|
+
`./App` and `./lifecycle` are exposed by `defineAppConfig()` already; pass
|
|
243
|
+
`exposes` only to add more:
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
// rsbuild.config.mts
|
|
247
|
+
defineAppConfig({ pkg, port: 5101, exposes: { './Widget': './src/Widget' } });
|
|
195
248
|
```
|
|
196
249
|
|
|
197
250
|
The shell invokes hooks best-effort: errors are logged, 10s timeout per hook, missing hooks skip silently. Hooks run inside the shell's page — `getShellApi()` / `getShellApiV4()` work from inside them.
|
|
@@ -617,9 +670,9 @@ function MyPanel({ flowOriginId }: { flowOriginId: string }) {
|
|
|
617
670
|
`QueryClient` from React context: federated apps get a **per-app client the
|
|
618
671
|
shell mounts** around them (isolated from the shell's own persisted cache and
|
|
619
672
|
from other apps), and everywhere else — standalone dev, older shells — the
|
|
620
|
-
hooks fall back to a per-bundle client automatically. The one requirement:
|
|
621
|
-
|
|
622
|
-
|
|
673
|
+
hooks fall back to a per-bundle client automatically. The one requirement:
|
|
674
|
+
react-query must be a share so the shell's context can cross the federation
|
|
675
|
+
boundary — the preset does this for you:
|
|
623
676
|
|
|
624
677
|
```js
|
|
625
678
|
shared: {
|
|
@@ -739,7 +792,7 @@ Apps build with [Rsbuild](https://rsbuild.dev), and the Module Federation
|
|
|
739
792
|
contract with the shell lives in this preset rather than in each app's config.
|
|
740
793
|
|
|
741
794
|
```ts
|
|
742
|
-
// rsbuild.config.
|
|
795
|
+
// rsbuild.config.mts
|
|
743
796
|
import { defineConfig } from '@rsbuild/core';
|
|
744
797
|
import { defineAppConfig } from '@rise-x/apps-sdk/rsbuild';
|
|
745
798
|
import pkg from './package.json';
|
|
@@ -755,9 +808,11 @@ pnpm rsbuild dev # federated, served for a host to load
|
|
|
755
808
|
pnpm rsbuild dev --env-mode standalone # standalone, no shell -> dist-local/
|
|
756
809
|
```
|
|
757
810
|
|
|
758
|
-
Requires `@rsbuild/core
|
|
811
|
+
Requires all three of `@rsbuild/core`, `@rsbuild/plugin-react` and
|
|
812
|
+
`@rsbuild/plugin-type-check` in the app — the preset imports each at module
|
|
813
|
+
level, so a missing one fails at config load with `MODULE_NOT_FOUND`. They are
|
|
759
814
|
optional peers here, so hosts that never import this subpath get no unmet-peer
|
|
760
|
-
noise
|
|
815
|
+
noise; the scaffolder puts all three in a new app's devDependencies.
|
|
761
816
|
|
|
762
817
|
| Option | Required | Purpose |
|
|
763
818
|
|---|---|---|
|
|
@@ -765,10 +820,38 @@ noise).
|
|
|
765
820
|
| `port` | yes | dev-server port. Must be unique across apps |
|
|
766
821
|
| `standalone` | no | no shell, no MF, React bundled in |
|
|
767
822
|
| `exposes` | no | extra MF exposes, merged over `./App` + `./lifecycle` |
|
|
823
|
+
| `define` | no | extra `source.define` entries, merged into the preset's own |
|
|
768
824
|
|
|
769
825
|
`__APP_VERSION__` is a `define`, so TypeScript needs to be told it exists. Add
|
|
770
826
|
`declare const __APP_VERSION__: string;` to the app if you read it.
|
|
771
827
|
|
|
828
|
+
The converse is the trap `define` exists for: a `declare const` in the app's
|
|
829
|
+
`global.d.ts` makes TypeScript accept the identifier whether or not the build
|
|
830
|
+
substitutes it. Declare one without passing it here and the app compiles clean,
|
|
831
|
+
then throws `ReferenceError` on load with nothing in the build output pointing
|
|
832
|
+
at the cause.
|
|
833
|
+
|
|
834
|
+
Values are raw code, not data — the same contract as webpack's `DefinePlugin` —
|
|
835
|
+
so a string arrives quoted. And because the option takes a fixed object, a value
|
|
836
|
+
that depends on the build has to be derived in the `defineConfig` callback:
|
|
837
|
+
|
|
838
|
+
```ts
|
|
839
|
+
export default defineConfig(({ envMode }) =>
|
|
840
|
+
defineAppConfig({
|
|
841
|
+
pkg,
|
|
842
|
+
port: 5101,
|
|
843
|
+
standalone: envMode === 'standalone',
|
|
844
|
+
define: {
|
|
845
|
+
__USE_SAMPLE_DATA__: String(envMode !== 'production'),
|
|
846
|
+
__API_LABEL__: JSON.stringify(envMode ?? 'development'),
|
|
847
|
+
},
|
|
848
|
+
}),
|
|
849
|
+
);
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
Passing `__APP_VERSION__` throws: it is derived from `pkg.version` so it always
|
|
853
|
+
matches the deployed manifest.
|
|
854
|
+
|
|
772
855
|
What the federated branch sets, and why it matters:
|
|
773
856
|
|
|
774
857
|
- **`ModuleFederationPluginV1`**, never the enhanced plugin — V1 emits the
|
|
@@ -786,9 +869,11 @@ What the federated branch sets, and why it matters:
|
|
|
786
869
|
That is a build-level permission, not a licence to use React 19 APIs — write
|
|
787
870
|
app code against the **React 18-compatible API surface**, since ClientApp is
|
|
788
871
|
still the production host.
|
|
789
|
-
- **Flat `dist/`** — `remoteEntry.js` beside its chunks
|
|
790
|
-
`tools/apps-dev-server` probes `dist/remoteEntry.js` and the
|
|
791
|
-
*contents* of `dist/`.
|
|
872
|
+
- **Flat `dist/`** — `remoteEntry.js` beside its chunks *and every emitted
|
|
873
|
+
asset*, because `tools/apps-dev-server` probes `dist/remoteEntry.js` and the
|
|
874
|
+
deploy zips the *contents* of `dist/`. Rsbuild would otherwise route assets
|
|
875
|
+
into `static/<kind>/`; the preset flattens all of them, which is also what the
|
|
876
|
+
webpack configs it replaces did.
|
|
792
877
|
- **`assetPrefix: 'auto'` on both `output` and `dev`** so one bundle works on
|
|
793
878
|
the dev port and when the shell loads `remoteEntry.js` from the CDN. Rsbuild
|
|
794
879
|
splits what webpack had as a single `output.publicPath`, and the dev half
|
|
@@ -825,7 +910,7 @@ pnpm add @rise-x/apps-sdk
|
|
|
825
910
|
|
|
826
911
|
## Publishing
|
|
827
912
|
|
|
828
|
-
Publishes to the public npm registry (`registry.npmjs.org`) under the `rise-x` org, per `publishConfig` in `package.json`. Releases are manual: run the **Publish @rise-x/apps-sdk** workflow (`.github/workflows/publish-apps-sdk.yml`) via workflow dispatch, from `main` or a `release/*` branch — it publishes the version in `package.json`, and fails if that version is already on the registry.
|
|
913
|
+
Publishes to the public npm registry (`registry.npmjs.org`) under the `rise-x` org, per `publishConfig` in `package.json`. Releases are manual: run the **Publish @rise-x/apps-sdk** workflow (`.github/workflows/publish-apps-sdk.yml`) via workflow dispatch, from `main` or a `release/*` branch — it publishes the version in `package.json`, and fails if that version is already on the registry. The run checks the version first, then pauses for approval on the `publish-apps-sdk` environment: a required reviewer must approve it before anything reaches npm.
|
|
829
914
|
|
|
830
915
|
To publish manually you need an npmjs account with publish rights in the `rise-x` org (`npm login`), then:
|
|
831
916
|
|
package/build/rsbuild/index.d.ts
CHANGED
|
@@ -22,10 +22,15 @@ export interface DefineAppConfigOptions {
|
|
|
22
22
|
standalone?: boolean;
|
|
23
23
|
/** Extra Module Federation exposes, merged over `./App` + `./lifecycle`. */
|
|
24
24
|
exposes?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Extra `source.define` entries. Values are raw code, so strings arrive
|
|
27
|
+
* quoted: `{ __MODE__: JSON.stringify('sample') }`. `__APP_VERSION__` throws.
|
|
28
|
+
*/
|
|
29
|
+
define?: Record<string, string>;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Derive an app's Module Federation scope from its package name:
|
|
28
33
|
* `@rise-x-apps/vendor-hub` -> `app_vendor_hub`.
|
|
29
34
|
*/
|
|
30
35
|
export declare function deriveAppScope(packageName: string): string;
|
|
31
|
-
export declare function defineAppConfig({ pkg, port, standalone, exposes, }: DefineAppConfigOptions): RsbuildConfig;
|
|
36
|
+
export declare function defineAppConfig({ pkg, port, standalone, exposes, define, }: DefineAppConfigOptions): RsbuildConfig;
|
package/build/rsbuild/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const SCOPE_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
|
26
26
|
// does not satisfy — it logs one warning per shared entry on every app load, and
|
|
27
27
|
// it states a constraint the apps do not actually have. Both hosts DERIVE the
|
|
28
28
|
// version they provide from the resolved package precisely so it cannot rot
|
|
29
|
-
// (see ClientApp/
|
|
29
|
+
// (see ClientApp/rsbuild.config.ts).
|
|
30
30
|
//
|
|
31
31
|
// The range matches this package's own `react` peer range, and
|
|
32
32
|
// apps/medication-identifier already ships it in production. Be precise about
|
|
@@ -56,7 +56,7 @@ function deriveAppScope(packageName) {
|
|
|
56
56
|
}
|
|
57
57
|
return scope;
|
|
58
58
|
}
|
|
59
|
-
function defineAppConfig({ pkg, port, standalone = false, exposes, }) {
|
|
59
|
+
function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
|
|
60
60
|
// APP_SCOPE overrides the derived scope, for the case where an app must be
|
|
61
61
|
// registered ALONGSIDE another build of itself (e.g. an old and a redesigned
|
|
62
62
|
// version, side by side, to compare them). Two registrations may not share a
|
|
@@ -71,6 +71,11 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, }) {
|
|
|
71
71
|
`(it must match ${SCOPE_PATTERN}).`);
|
|
72
72
|
}
|
|
73
73
|
const scope = override || deriveAppScope(pkg.name);
|
|
74
|
+
if (define && '__APP_VERSION__' in define) {
|
|
75
|
+
throw new Error('defineAppConfig: __APP_VERSION__ cannot be set through `define` — it is derived ' +
|
|
76
|
+
'from pkg.version so it always matches the deployed manifest. Change the version ' +
|
|
77
|
+
'in package.json instead.');
|
|
78
|
+
}
|
|
74
79
|
const base = {
|
|
75
80
|
// pluginTypeCheck is NOT optional polish. The webpack configs this preset
|
|
76
81
|
// replaces used ts-loader, which type-checked on every build, and that pass
|
|
@@ -84,6 +89,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, }) {
|
|
|
84
89
|
source: {
|
|
85
90
|
entry: { index: './src/index.tsx' },
|
|
86
91
|
define: {
|
|
92
|
+
...define,
|
|
87
93
|
__APP_VERSION__: JSON.stringify(pkg.version ?? '0.0.0'),
|
|
88
94
|
},
|
|
89
95
|
},
|
|
@@ -133,7 +139,22 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, }) {
|
|
|
133
139
|
// Flat dist: remoteEntry.js plus its sibling chunks at the archive root.
|
|
134
140
|
// tools/apps-dev-server probes `dist/remoteEntry.js`, and the deploy zips
|
|
135
141
|
// the CONTENTS of dist/ with remoteEntry.js at the top level.
|
|
136
|
-
|
|
142
|
+
// Every asset bucket flattened, matching the webpack configs this replaces;
|
|
143
|
+
// Rsbuild would otherwise nest them under `static/<kind>/`. Tracks Rsbuild's
|
|
144
|
+
// own distPath keys, so revisit on a major. `html` already defaults to root.
|
|
145
|
+
distPath: {
|
|
146
|
+
root: 'dist',
|
|
147
|
+
js: '',
|
|
148
|
+
jsAsync: '',
|
|
149
|
+
css: '',
|
|
150
|
+
cssAsync: '',
|
|
151
|
+
svg: '',
|
|
152
|
+
font: '',
|
|
153
|
+
image: '',
|
|
154
|
+
media: '',
|
|
155
|
+
assets: '',
|
|
156
|
+
wasm: '',
|
|
157
|
+
},
|
|
137
158
|
// 'auto' derives the chunk base URL from document.currentScript.src at
|
|
138
159
|
// runtime, so one bundle works both in dev and when the shell loads
|
|
139
160
|
// remoteEntry.js from the CDN under /apps/<id>/<version>/.
|