@servicetitan/docs-uikit 36.4.0 → 37.0.0
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/docs/BREAKING_CHANGES.mdx +8 -0
- package/docs/ai-marketplace.mdx +3 -0
- package/docs/datadog-rum.mdx +59 -18
- package/docs/eslint-config.mdx +10 -10
- package/docs/install.mdx +1 -1
- package/docs/microfrontends/hosting.mdx +1 -1
- package/docs/startup/build/build.mdx +93 -12
- package/docs/startup/build/optional-peer-dependencies.mdx +131 -0
- package/docs/startup/build/vite.mdx +24 -7
- package/docs/startup/build/webpack.mdx +18 -8
- package/docs/startup/clean.mdx +1 -1
- package/docs/startup/lint.mdx +1 -1
- package/docs/startup/mfe-list.mdx +2 -2
- package/docs/startup/review.mdx +36 -11
- package/docs/startup/start/start.mdx +8 -8
- package/docs/startup/start/vite.mdx +29 -10
- package/docs/startup/start/webpack.mdx +13 -3
- package/docs/startup/startup.mdx +95 -26
- package/docs/startup/test/jest.mdx +4 -4
- package/docs/startup/test/test.mdx +1 -1
- package/docs/startup/test/vitest.mdx +6 -6
- package/package.json +2 -2
|
@@ -3,6 +3,14 @@ title: BREAKING CHANGES
|
|
|
3
3
|
sidebar_position: 0
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
## v37.0.0
|
|
7
|
+
|
|
8
|
+
### [@servicetitan/startup](./startup/)
|
|
9
|
+
|
|
10
|
+
Upgraded TypeScript from 5.x to 6.x, which turns several deprecated `tsconfig` options into hard errors and changes compiler defaults that can surface as new errors in consumer projects.
|
|
11
|
+
|
|
12
|
+
See the [TypeScript 6 upgrade guide](https://docs.st.dev/docs/frontend/upgrading-to-typescript-6) for the breaking changes and the `migrating-to-typescript-6` skill that automates the mechanical fixes.
|
|
13
|
+
|
|
6
14
|
## v36.0.0
|
|
7
15
|
|
|
8
16
|
### [@servicetitan/startup](./startup/)
|
package/docs/ai-marketplace.mdx
CHANGED
|
@@ -89,6 +89,9 @@ Shared uikit skills for ServiceTitan repos.
|
|
|
89
89
|
|
|
90
90
|
| Name | Description |
|
|
91
91
|
| :---------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
92
|
+
| `check-shai-hulud` | Scan a developer machine for indicators of compromise from the 2026-05-19 Mini Shai-Hulud npm supply chain attack |
|
|
93
|
+
| `check-supply-chain` | Scan a developer machine for signs of npm supply chain compromise; routes to wave-specific skills such as `check-shai-hulud` |
|
|
94
|
+
| `running-startup-commands` | Run tests, lint, and builds via the `startup` CLI in projects that depend on `@servicetitan/startup` |
|
|
92
95
|
| `spell-check` | Check for spelling errors in code changes |
|
|
93
96
|
| `switching-to-pnpm` | Migrate a project from npm to pnpm (see [migration guide](/docs/frontend/switching-to-pnpm)) |
|
|
94
97
|
| `updating-mfe-check-workflow` | Diagnose and fix `mfe-check-shared-dependencies` workflow failures after the FAR-1776 reusable-workflow rewrite (validates each `mfe-path`/`host-path`) |
|
package/docs/datadog-rum.mdx
CHANGED
|
@@ -195,25 +195,26 @@ cleanup();
|
|
|
195
195
|
|
|
196
196
|
##### `InitRumOptions` {#initrumoptions}
|
|
197
197
|
|
|
198
|
-
| Name | Type
|
|
199
|
-
| :------------ |
|
|
200
|
-
| `service` | [`ServiceConfig`](#serviceconfig)
|
|
201
|
-
| `application` | [`ApplicationConfig`](#applicationconfig)
|
|
198
|
+
| Name | Type | Description |
|
|
199
|
+
| :------------ | :---------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
200
|
+
| `service` | [`ServiceConfig`](#serviceconfig) | Per-service handlers and tracing URL matchers |
|
|
201
|
+
| `application` | [`ApplicationConfig`](#applicationconfig) | (optional) SDK initialization config; first caller wins |
|
|
202
|
+
| `enabled` | `boolean` | (optional) Controls whether Datadog RUM data collection is turned on. Defaults to `true`. Set this instead of gating the `init` call to allow [runtime enablement for development](#dev-runtime-enable). |
|
|
202
203
|
|
|
203
204
|
##### `RumServiceRegistration` {#rumserviceregistration}
|
|
204
205
|
|
|
205
|
-
| Name | Type
|
|
206
|
-
| :------------------ |
|
|
207
|
-
| `cleanup` | `() => void`
|
|
208
|
-
| `setServiceContext` | `(context: Context) => void`
|
|
206
|
+
| Name | Type | Description |
|
|
207
|
+
| :------------------ | :--------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
208
|
+
| `cleanup` | `() => void` | Removes this service's `beforeSend`, `allowedTracingUrls`, and persistent context. Idempotent. |
|
|
209
|
+
| `setServiceContext` | `(context: Context) => void` | Sets session-lifetime context merged into every event whose `event.service` matches this service's name. Replace semantics: a second call replaces the previous bag with no merge. |
|
|
209
210
|
|
|
210
211
|
##### `ServiceConfig` {#serviceconfig}
|
|
211
212
|
|
|
212
|
-
| Name | Type
|
|
213
|
-
| :------------------- |
|
|
214
|
-
| `name` | `string`
|
|
215
|
-
| `beforeSend` | `ServiceBeforeSendHandler`
|
|
216
|
-
| `allowedTracingUrls` | `Partial<Record<PropagatorType, TracingMatchOption[]>>` | (optional) URL matchers grouped by propagator type
|
|
213
|
+
| Name | Type | Description |
|
|
214
|
+
| :------------------- | :------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
215
|
+
| `name` | `string` | Service name. For MFEs loaded from unpkg, must exactly match the unscoped `package.json` `name` (e.g. `'task-hub'` for `@servicetitan/task-hub`). |
|
|
216
|
+
| `beforeSend` | `ServiceBeforeSendHandler` | (optional) Transform-only per-service handler. Return value is **ignored** — services cannot drop events. |
|
|
217
|
+
| `allowedTracingUrls` | `Partial<Record<PropagatorType, TracingMatchOption[]>>` | (optional) URL matchers grouped by propagator type |
|
|
217
218
|
|
|
218
219
|
:::caution
|
|
219
220
|
A service's `beforeSend` cannot drop events. This is intentional: services share a session with the host and any other MFEs, so a bug in one service must not silently hide its own events from the host's monitoring. Use `application.beforeSend` for app-wide drop decisions.
|
|
@@ -223,8 +224,8 @@ A service's `beforeSend` cannot drop events. This is intentional: services share
|
|
|
223
224
|
|
|
224
225
|
Same shape as `datadogRum.init` config, minus `allowedTracingUrls` (built from service registrations) and `service` (derived from `service.name`), plus:
|
|
225
226
|
|
|
226
|
-
| Name | Type
|
|
227
|
-
| :----------- |
|
|
227
|
+
| Name | Type | Description |
|
|
228
|
+
| :----------- | :----------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
|
|
228
229
|
| `beforeSend` | `ApplicationBeforeSendHandler` | (optional) Application-level handler; runs for all events before service handlers. Return `false` to drop the event app-wide. |
|
|
229
230
|
|
|
230
231
|
Opinionated defaults (overridable):
|
|
@@ -276,6 +277,46 @@ const TaskHub = () => {
|
|
|
276
277
|
|
|
277
278
|
The hook accepts a [`ServiceConfig`](#serviceconfig) — the same shape used by `init`'s `service` field. It does **not** accept `application` config, since SDK initialization shouldn't be tied to a component's lifecycle.
|
|
278
279
|
|
|
280
|
+
### Enabling RUM at runtime for development {#dev-runtime-enable}
|
|
281
|
+
|
|
282
|
+
To exercise RUM-related changes in an environment where the application ships RUM but leaves it off (for example a local or QA build), you can turn RUM on for your own browser — no code change. It only ever turns RUM **on**; it has no effect where RUM is already enabled.
|
|
283
|
+
|
|
284
|
+
An application opts in once by always calling [`init`](#init) and passing its enablement decision as `enabled`, instead of gating the `init` call:
|
|
285
|
+
|
|
286
|
+
```ts title="datadog-entry.ts"
|
|
287
|
+
import { init } from '@servicetitan/datadog-rum';
|
|
288
|
+
|
|
289
|
+
const isEnabled = /.*go\d*\.servicetitan\.com/.test(window.location.hostname);
|
|
290
|
+
|
|
291
|
+
init({
|
|
292
|
+
service: { name: 'desktop' },
|
|
293
|
+
application: {
|
|
294
|
+
applicationId: '<APPLICATION_ID>',
|
|
295
|
+
clientToken: '<CLIENT_TOKEN>',
|
|
296
|
+
env: window.location.hostname,
|
|
297
|
+
},
|
|
298
|
+
enabled: isEnabled,
|
|
299
|
+
});
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
In any environment where the application ships RUM but leaves it disabled (`enabled` is `false`), the package exposes `datadogRumForDev` on the global scope. A developer controls it directly from the browser devtools console — no import, no code change:
|
|
303
|
+
|
|
304
|
+
```js
|
|
305
|
+
// In the browser devtools console:
|
|
306
|
+
datadogRumForDev.start(); // turn RUM on for the next 12 hours
|
|
307
|
+
datadogRumForDev.stop(); // clear the override; return to the shipped default
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`start()` records the override in `localStorage` and reloads the page to apply. The override expires automatically after 12 hours; calling `start()` again refreshes the 12-hour window. `stop()` removes the override, ends the current Datadog session, and reloads — returning to the application's shipped `enabled` value. It does **not** disable RUM that the application itself enabled. Both methods log to the console, so the override is never silent.
|
|
311
|
+
|
|
312
|
+
Sessions enabled this way are tagged with a `datadogRumForDev` context attribute. Filter `@context.datadogRumForDev:true` in Datadog RUM to find them, or `-@context.datadogRumForDev:true` to exclude them from production dashboards.
|
|
313
|
+
|
|
314
|
+
**Set `env` per host before relying on this** (e.g. `env: window.location.hostname`, as above). Because the override turns RUM on in an environment that normally doesn't report, a static or hardcoded `env` would file those dev sessions under your **production** `env` — colliding with prod data in dashboards and SLOs. A dynamic `env` keeps override-enabled lower-environment sessions in their own bucket.
|
|
315
|
+
|
|
316
|
+
#### Multiple tabs
|
|
317
|
+
|
|
318
|
+
Because the override lives in `localStorage`, it applies to every tab of the origin — useful for testing how a user navigates between pages and opens new tabs. Calling `start()` (or `stop()`) reloads the current tab and every other open tab of the application, so they all pick up the change. A tab opened afterward honors the override on its first load. All such tabs share a single Datadog RUM session, exactly as they would with normally-enabled RUM.
|
|
319
|
+
|
|
279
320
|
### `DatadogProvider`
|
|
280
321
|
|
|
281
322
|
`DatadogProvider` provides the RUM SDK with:
|
|
@@ -334,9 +375,9 @@ const Root = () => {
|
|
|
334
375
|
import type { RumUser } from '@servicetitan/datadog-rum';
|
|
335
376
|
```
|
|
336
377
|
|
|
337
|
-
| Name | Type | Description
|
|
338
|
-
| :-------------- | :----------------------------- |
|
|
339
|
-
| `id` | `string` | User ID
|
|
378
|
+
| Name | Type | Description |
|
|
379
|
+
| :-------------- | :----------------------------- | :-------------------------------------- |
|
|
380
|
+
| `id` | `string` | User ID |
|
|
340
381
|
| `[key: string]` | `string \| number \| string[]` | (optional) Session-wide user attributes |
|
|
341
382
|
|
|
342
383
|
##### `Options`
|
package/docs/eslint-config.mdx
CHANGED
|
@@ -22,7 +22,7 @@ The ESLint config bundles rules from ESLint core, `eslint-plugin-import`, `eslin
|
|
|
22
22
|
|
|
23
23
|
#### In the Lerna project
|
|
24
24
|
|
|
25
|
-
Use `mono` in a
|
|
25
|
+
Use `mono` in a monorepo. It discovers every package at lint time and wires up `import/no-extraneous-dependencies` for each one, so imports are checked against both the package's own `package.json` and the repo root.
|
|
26
26
|
|
|
27
27
|
```js title="eslint.config.js"
|
|
28
28
|
import { defineConfig } from 'eslint/config';
|
|
@@ -68,13 +68,13 @@ This rule requires a QA selector attribute on interactive elements so tests can
|
|
|
68
68
|
|
|
69
69
|
**1. Interactive Anvil2 components.** The rule tracks imports from `@servicetitan/anvil2` and `@servicetitan/anvil2/beta`, then flags any of these components when rendered without a QA attribute. Aliased imports (for example, `Button as Btn`) resolve to the original export name before the check runs.
|
|
70
70
|
|
|
71
|
-
| Category
|
|
72
|
-
|
|
|
73
|
-
| Form inputs
|
|
74
|
-
| Selection
|
|
75
|
-
| Actions
|
|
76
|
-
| Navigation
|
|
77
|
-
| Overlays, menus | `Menu`, `Menu.Item`, `Popover.Button`, `Popover.Close`, `Tab.Button`, `EditCard`, `Chip`
|
|
71
|
+
| Category | Components |
|
|
72
|
+
| :-------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| Form inputs | `Checkbox`, `Radio`, `Switch`, `TextField`, `Textarea`, `NumberField`, `SearchField`, `TimeField`, `DateField`, `DateFieldRange`, `DateFieldSingle`, `DateFieldYearless`, `Calendar`, `Pagination` |
|
|
74
|
+
| Selection | `SelectCard`, `SegmentedControl`, `DaysOfTheWeek`, `SelectTrigger`, `Combobox.SearchField`, `Combobox.SelectTrigger` |
|
|
75
|
+
| Actions | `Button`, `ButtonToggle`, `Link`, `Toolbar.Button`, `Toolbar.ButtonToggle`, `Toolbar.ButtonLink`, `Toolbar.Select` |
|
|
76
|
+
| Navigation | `SideNavLink`, `SideNavCollapsible`, `SideNav.Link`, `SideNav.Collapsible`, `BreadcrumbsLink`, `Breadcrumbs.Link`, `Stepper.PrevButton`, `Stepper.NextButton`, `Stepper.Step` |
|
|
77
|
+
| Overlays, menus | `Menu`, `Menu.Item`, `Popover.Button`, `Popover.Close`, `Tab.Button`, `EditCard`, `Chip` |
|
|
78
78
|
|
|
79
79
|
**2. Direct children of `Tooltip.Trigger` or `Popover.Trigger`.** The trigger forwards interactions to its child, so the attribute belongs on the child element rather than the trigger itself.
|
|
80
80
|
|
|
@@ -84,8 +84,8 @@ The rule skips elements that use JSX spread (`{...props}`), since the QA attribu
|
|
|
84
84
|
|
|
85
85
|
###### Options
|
|
86
86
|
|
|
87
|
-
| Name | Type | Default
|
|
88
|
-
| :----------- | :--------- |
|
|
87
|
+
| Name | Type | Default | Description |
|
|
88
|
+
| :----------- | :--------- | :------------ | :------------------------------------------------------------------------------- |
|
|
89
89
|
| `attributes` | `string[]` | `['data-cy']` | Acceptable attribute names. At least one must be present on the flagged element. |
|
|
90
90
|
|
|
91
91
|
The example below shows two ways to enable the rule. The first call uses the defaults and requires `data-cy`. The second call passes a `rules` override so the rule accepts `data-testid` instead, which is useful for projects that already use a different attribute convention.
|
package/docs/install.mdx
CHANGED
|
@@ -40,7 +40,7 @@ The `npx --yes @servicetitan/install` command works regardless of which package
|
|
|
40
40
|
|
|
41
41
|
### pnpm support
|
|
42
42
|
|
|
43
|
-
✨ New in **
|
|
43
|
+
✨ New in **v36.2.0** ✨
|
|
44
44
|
|
|
45
45
|
`@servicetitan/startup` includes experimental pnpm support. See the [Switching to pnpm](/docs/frontend/switching-to-pnpm) migration guide to get started.
|
|
46
46
|
|
|
@@ -9,7 +9,7 @@ A host is an application, or MFE, that uses [`Loader`](../web-components/loader)
|
|
|
9
9
|
Set `cli.expose-shared-dependencies` to `true` in the application's `package.json`.
|
|
10
10
|
|
|
11
11
|
:::caution
|
|
12
|
-
`expose-shared-dependencies` only applies to applications. MFEs that load other MFEs do not need this setting or any additional configuration.
|
|
12
|
+
`expose-shared-dependencies` only applies to applications. MFEs that load other MFEs do not need this setting or any additional configuration. Setting it on a package marked `cli.web-component` fails the build.
|
|
13
13
|
:::
|
|
14
14
|
|
|
15
15
|
```json title="package.json"
|
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
title: build
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
Build packages for production to the `dist/bundle` folders. It bundles them in production mode and optimizes the build for the best performance. The builds are minified and the filenames include the hashes. Apps are ready to be deployed.
|
|
6
9
|
|
|
7
|
-
`startup` supports two bundlers: [Webpack](./webpack) (default) and [Vite](./vite) (opt-in via `--
|
|
10
|
+
`startup` supports two bundlers: [Webpack](./webpack) (default) and [Vite](./vite) (opt-in via `--bundler=vite`).
|
|
8
11
|
|
|
9
12
|
## Options
|
|
10
13
|
|
|
11
|
-
| Option | Webpack | Vite
|
|
12
|
-
| :----------------- | :------ |
|
|
13
|
-
| `--scope <glob>` | Yes | Yes
|
|
14
|
-
| `--ignore <glob>` | Yes | Yes
|
|
15
|
-
| `--cdn-path <url>` | Yes |
|
|
16
|
-
| `--stat` | Yes |
|
|
17
|
-
| `--code-coverage` | Yes |
|
|
18
|
-
| `--use-tsc` | Yes | Yes
|
|
19
|
-
| `--
|
|
20
|
-
| `--preview` | No | Yes
|
|
21
|
-
| `--config <path>` | Yes | No
|
|
14
|
+
| Option | Webpack | Vite | Description |
|
|
15
|
+
| :----------------- | :------ | :--- | :------------------------------------------------------------------------ |
|
|
16
|
+
| `--scope <glob>` | Yes | Yes | Include only packages with names matching the given glob. |
|
|
17
|
+
| `--ignore <glob>` | Yes | Yes | Exclude packages with names matching the given glob. |
|
|
18
|
+
| `--cdn-path <url>` | Yes | Yes | Specify the base path for all the assets within the application. |
|
|
19
|
+
| `--stat` | Yes | Yes | Generate bundle analysis report. |
|
|
20
|
+
| `--code-coverage` | Yes | Yes | Add instrumentation to bundled code in order to collect code coverage. |
|
|
21
|
+
| `--use-tsc` | Yes | Yes | Use TSC for TypeScript compilation. |
|
|
22
|
+
| `--bundler <name>` | Yes | Yes | Select the bundler: `vite` or `webpack` (default). |
|
|
23
|
+
| `--preview` | No | Yes | Preview production build locally via a static server. |
|
|
24
|
+
| `--config <path>` | Yes | No | Custom config file path. Vite uses convention-based config files instead. |
|
|
22
25
|
|
|
23
26
|
## Build Steps
|
|
24
27
|
|
|
@@ -128,6 +131,10 @@ Set `cli.webpack` or `cli.vite` to `false` to disable bundling for non-applicati
|
|
|
128
131
|
}
|
|
129
132
|
```
|
|
130
133
|
|
|
134
|
+
:::caution
|
|
135
|
+
`cli.webpack` and `cli.vite` must agree. Setting one to `false` while the other is configured is contradictory and fails the build. To disable bundling, set `cli.webpack` or `cli.vite` to `false` and leave the other unset, or set both to `false`.
|
|
136
|
+
:::
|
|
137
|
+
|
|
131
138
|
### Type Checking
|
|
132
139
|
|
|
133
140
|
Use package-specific `tsconfig.json` and `tsconfig.build.json` files to set or override type checking options. E.g.,
|
|
@@ -162,6 +169,60 @@ Use `tsconfig.build.json` that extends from `tsconfig.json` to exclude tests, st
|
|
|
162
169
|
Project references must be duplicated in `tsconfig.build.json` because [references are not inherited](https://github.com/microsoft/TypeScript/issues/27098).
|
|
163
170
|
:::
|
|
164
171
|
|
|
172
|
+
#### Root-Level Config Files {#root-level-config-files}
|
|
173
|
+
|
|
174
|
+
By default, TypeScript checks only the files inside the package `rootDir`, so config files that sit outside it, like `vite.*.config.ts`, get neither type checking nor type-aware linting. Helpers like `defineConfig` give you IDE autocomplete through the language service, but otherwise nothing checks these files.
|
|
175
|
+
|
|
176
|
+
To cover them, add a second compilation unit that doesn't impose `rootDir`. The split looks slightly different depending on the project shape:
|
|
177
|
+
|
|
178
|
+
<Tabs
|
|
179
|
+
defaultValue="monorepo"
|
|
180
|
+
values={[
|
|
181
|
+
{ label: 'Monorepo', value: 'monorepo' },
|
|
182
|
+
{ label: 'Single Package', value: 'single' },
|
|
183
|
+
]}
|
|
184
|
+
>
|
|
185
|
+
<TabItem value="monorepo">
|
|
186
|
+
|
|
187
|
+
The split lives one level up: a root `tsconfig.json` whose `include` covers root-level configs sits above the per-package tsconfigs scoped to `src/`. For example,
|
|
188
|
+
|
|
189
|
+
```json title="tsconfig.json"
|
|
190
|
+
{
|
|
191
|
+
"extends": "@servicetitan/startup/tsconfig/base",
|
|
192
|
+
"include": ["*.ts", "**/vite.*.config.ts"]
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
</TabItem>
|
|
197
|
+
<TabItem value="single">
|
|
198
|
+
|
|
199
|
+
Create a sibling `tsconfig.node.json` and reference it from the main `tsconfig.json`:
|
|
200
|
+
|
|
201
|
+
```json title="tsconfig.json"
|
|
202
|
+
{
|
|
203
|
+
"extends": "@servicetitan/startup/tsconfig/base",
|
|
204
|
+
"compilerOptions": {
|
|
205
|
+
"outDir": "dist",
|
|
206
|
+
"rootDir": "src"
|
|
207
|
+
},
|
|
208
|
+
"include": ["src/**/*"],
|
|
209
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```json title="tsconfig.node.json"
|
|
214
|
+
{
|
|
215
|
+
"extends": "@servicetitan/startup/tsconfig/base",
|
|
216
|
+
"compilerOptions": { "composite": true },
|
|
217
|
+
"include": ["*.ts"]
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The `*.ts` glob is non-recursive and picks up only root-level config files. The `tsconfig.node.json` filename follows the Vite convention. The include itself is general and not specific to Vite.
|
|
222
|
+
|
|
223
|
+
</TabItem>
|
|
224
|
+
</Tabs>
|
|
225
|
+
|
|
165
226
|
### TypeScript Compilation (SWC)
|
|
166
227
|
|
|
167
228
|
:::info
|
|
@@ -194,6 +255,26 @@ Compilation via TSC is deprecated.
|
|
|
194
255
|
|
|
195
256
|
Use package-specific `tsconfig.json` and `tsconfig.build.json` files to set or override compiler options. See [Type checking](#type-checking) for more information.
|
|
196
257
|
|
|
258
|
+
### Exposing Environment Variables
|
|
259
|
+
|
|
260
|
+
✨ New in **v37.0.0** ✨
|
|
261
|
+
|
|
262
|
+
To forward a `process.env` variable (for example an API URL) into client code that reads `process.env.NAME`, list its name under `cli.expose-process-env`. At build time `startup` replaces the `process.env.NAME` references with the variable's value. A variable unset at build time resolves to `undefined`.
|
|
263
|
+
|
|
264
|
+
```json title="package.json"
|
|
265
|
+
{
|
|
266
|
+
"cli": {
|
|
267
|
+
"expose-process-env": ["API_URL", "CLIENT_CDN_PATH", "FEATURE_FLAG"]
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Names are matched case-sensitively, so use the conventional `ALL_CAPS` form.
|
|
273
|
+
|
|
274
|
+
:::note
|
|
275
|
+
This is a convenient, package.json-only way to forward variables straight from the environment. It does not replace webpack's `DefinePlugin` or Vite's `define`, which map a name to a value you specify (not necessarily the live environment value). Use those when you need to control the value and use `expose-process-env` when you just want to pass an environment value through as-is.
|
|
276
|
+
:::
|
|
277
|
+
|
|
197
278
|
### Bundler-Specific Configuration
|
|
198
279
|
|
|
199
280
|
See [Webpack](./webpack) or [Vite](./vite) for bundler-specific configuration options, including minimization, custom config files, and plugin overrides.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Optional peer dependencies (internal)
|
|
3
|
+
draft: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
:::note
|
|
7
|
+
**Internal mechanism, not a supported public API.** This page is a Docusaurus `draft`: it is excluded from the published site and visible only in local `docusaurus start`. It documents, for maintainers, how `startup` lets uikit's own packages (for example `@servicetitan/web-components`) keep optional peers such as `@servicetitan/design-system` tree-shakeable. Outside consumers should not rely on `cli.peerDependenciesMeta`.
|
|
8
|
+
:::
|
|
9
|
+
|
|
10
|
+
A library marks a peer as optional via npm's [`peerDependenciesMeta`](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#peerdependenciesmeta). Consumers may or may not install it, but the library's source still references it, so the bundler has to decide what to do when the package is missing.
|
|
11
|
+
|
|
12
|
+
`startup` resolves missing optional peers to a stub module. The library picks the stub mode via `cli.peerDependenciesMeta[<pkg>].fallback`:
|
|
13
|
+
|
|
14
|
+
| Mode | Summary |
|
|
15
|
+
| :------ | :-------------------------------------------------------------------------- |
|
|
16
|
+
| `throw` | Stub throws when the missing peer is referenced. This is the default value. |
|
|
17
|
+
| `empty` | Stub resolves to a module with no exports. |
|
|
18
|
+
|
|
19
|
+
`throw` is the default and needs no extra configuration beyond marking the peer optional:
|
|
20
|
+
|
|
21
|
+
```json title="package.json"
|
|
22
|
+
{
|
|
23
|
+
"peerDependenciesMeta": {
|
|
24
|
+
"react-router-dom": { "optional": true }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To switch a specific peer to `empty`, add `cli.peerDependenciesMeta[<pkg>].fallback`. `cli.peerDependenciesMeta` only carries the `fallback` value; npm's `peerDependenciesMeta[<pkg>].optional: true` is still required:
|
|
30
|
+
|
|
31
|
+
```json title="package.json"
|
|
32
|
+
{
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"react-router-dom": { "optional": true }
|
|
35
|
+
},
|
|
36
|
+
"cli": {
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"react-router-dom": { "fallback": "empty" }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The setting applies to both webpack and Vite builds.
|
|
45
|
+
|
|
46
|
+
## `throw` (default)
|
|
47
|
+
|
|
48
|
+
Stub throws `Cannot find module '<pkg>'` when evaluated.
|
|
49
|
+
|
|
50
|
+
Top-level static imports of the missing peer crash the importing module:
|
|
51
|
+
|
|
52
|
+
```ts title="src/optional-feature.ts"
|
|
53
|
+
/*
|
|
54
|
+
* If 'optional' is not installed, importing this file throws
|
|
55
|
+
* "Cannot find module 'optional'". Any module that imports
|
|
56
|
+
* './optional-feature' will fail to evaluate too.
|
|
57
|
+
*/
|
|
58
|
+
import { something } from 'optional';
|
|
59
|
+
|
|
60
|
+
export function doSomething() {
|
|
61
|
+
return something();
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`try { require(...) } catch {}` lets the library detect a missing peer without crashing:
|
|
66
|
+
|
|
67
|
+
```ts title="src/optional-feature.ts"
|
|
68
|
+
let optional;
|
|
69
|
+
try {
|
|
70
|
+
optional = require('optional');
|
|
71
|
+
} catch {
|
|
72
|
+
// peer not installed
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function doSomething() {
|
|
76
|
+
return optional ? optional.something() : doFallback();
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
:::caution
|
|
81
|
+
The `try { require(...) } catch {}` pattern works under webpack but not under Vite, since Vite/Rolldown does not support bare `require` in ESM source. It also defeats tree-shaking: `require()` pulls the whole package into the bundle. Prefer the [`empty`](#empty) fallback with `import * as X`, which tree-shakes to the used exports.
|
|
82
|
+
:::
|
|
83
|
+
|
|
84
|
+
## `empty`
|
|
85
|
+
|
|
86
|
+
Stub has no exports. All members of the imported namespace are `undefined`.
|
|
87
|
+
|
|
88
|
+
`import * as X` lets the library detect a missing peer by probing for an expected member, and tree-shakes to only the exports it uses:
|
|
89
|
+
|
|
90
|
+
```ts title="src/optional-feature.ts"
|
|
91
|
+
import * as optional from 'optional';
|
|
92
|
+
|
|
93
|
+
export function doSomething() {
|
|
94
|
+
if (optional.something === undefined) {
|
|
95
|
+
// peer not installed
|
|
96
|
+
return doFallback();
|
|
97
|
+
}
|
|
98
|
+
return optional.something();
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Why not dynamic `import()`?
|
|
103
|
+
|
|
104
|
+
A dynamic `import()` can be wrapped in `try/catch`, so it looks like a way to tolerate a missing peer. Two reasons it is a poor fit:
|
|
105
|
+
|
|
106
|
+
- **It is async.** `import()` returns a promise, so the value is not available synchronously. Consuming it from synchronous code (for example a React component that renders a provider inline) forces the call site into `await`/`Suspense`, which a static `import * as X` avoids.
|
|
107
|
+
|
|
108
|
+
- **Its tree-shaking is fragile.** It survives only when a single member is read directly on the import result. Destructuring several members at once, or storing the namespace, pulls the whole package in:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// tree-shakes: one member, read directly on the result
|
|
112
|
+
let something;
|
|
113
|
+
try {
|
|
114
|
+
something = (await import('optional')).something;
|
|
115
|
+
} catch {
|
|
116
|
+
// peer not installed
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// does NOT tree-shake: whole namespace stored, then used later
|
|
120
|
+
let optional;
|
|
121
|
+
try {
|
|
122
|
+
optional = await import('optional');
|
|
123
|
+
} catch {}
|
|
124
|
+
optional?.something();
|
|
125
|
+
|
|
126
|
+
// does NOT tree-shake: destructuring several members at once
|
|
127
|
+
let a, b;
|
|
128
|
+
try {
|
|
129
|
+
({ a, b } = await import('optional'));
|
|
130
|
+
} catch {}
|
|
131
|
+
```
|
|
@@ -2,14 +2,26 @@
|
|
|
2
2
|
title: Vite
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
✨ New in **
|
|
5
|
+
✨ New in **v37.0.0** ✨
|
|
6
6
|
|
|
7
|
-
Vite is an alternative bundler for `startup build`, enabled with
|
|
7
|
+
Vite is an alternative bundler for `startup build`, enabled with `--bundler=vite`. It uses [Vite](https://vite.dev/) with the [Rolldown](https://rolldown.rs/) bundler and [OXC](https://oxc.rs/) minifier/transformer.
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npx startup build --
|
|
10
|
+
npx startup build --bundler=vite
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
To make Vite the default, set `cli.bundler` in the project's root `package.json`:
|
|
14
|
+
|
|
15
|
+
```json title="package.json"
|
|
16
|
+
{
|
|
17
|
+
"cli": {
|
|
18
|
+
"bundler": "vite"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The `--bundler` flag overrides it per invocation.
|
|
24
|
+
|
|
13
25
|
:::tip
|
|
14
26
|
For dev server configuration (port, proxy, HMR), see [Vite start](../start/vite).
|
|
15
27
|
:::
|
|
@@ -118,10 +130,18 @@ For direct Vite configuration, use `cli.vite.config` in package.json. It accepts
|
|
|
118
130
|
}
|
|
119
131
|
```
|
|
120
132
|
|
|
133
|
+
:::note
|
|
134
|
+
A custom `build.outDir` is not honored for MFEs. Their bundles must reside in `dist/bundle/<subdir>` so the host loader can resolve them.
|
|
135
|
+
:::
|
|
136
|
+
|
|
121
137
|
## Config Files (`defineConfig`)
|
|
122
138
|
|
|
123
139
|
For advanced configuration, create `vite.dev.config.ts` (development) or `vite.prod.config.ts` (production) in the package root. Config files support full Vite `UserConfig` including `plugins`.
|
|
124
140
|
|
|
141
|
+
:::tip
|
|
142
|
+
Config files at the package root fall outside the main `tsconfig.json`, so they get no type checking on build or in CI. See [type checking root-level config files](./build#root-level-config-files) to enable it.
|
|
143
|
+
:::
|
|
144
|
+
|
|
125
145
|
Import `defineConfig` from `@servicetitan/startup/vite` for type safety:
|
|
126
146
|
|
|
127
147
|
```ts title="vite.prod.config.ts"
|
|
@@ -259,7 +279,7 @@ Use the `--preview` flag to start preview servers for all bundled packages after
|
|
|
259
279
|
Unlike `startup start`, preview servers serve only the built static assets: no source transformation, no hot reloading.
|
|
260
280
|
|
|
261
281
|
```sh
|
|
262
|
-
npx startup build --
|
|
282
|
+
npx startup build --bundler=vite --preview
|
|
263
283
|
```
|
|
264
284
|
|
|
265
285
|
The preview server is useful for validating production builds locally before deploying.
|
|
@@ -269,6 +289,3 @@ The preview server is useful for validating production builds locally before dep
|
|
|
269
289
|
The following features are planned but not yet available with the Vite bundler:
|
|
270
290
|
|
|
271
291
|
- `--stat`: bundle analysis report
|
|
272
|
-
- `--code-coverage`: code instrumentation for coverage
|
|
273
|
-
- `--cdn-path`: CDN public path
|
|
274
|
-
- Storybook configuration
|
|
@@ -6,12 +6,18 @@ Webpack is the default bundler for `startup build`.
|
|
|
6
6
|
|
|
7
7
|
## Minimization
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fidelity for source map debugging.
|
|
12
|
-
It uses [TerserWebpackPlugin](https://webpack.js.org/plugins/terser-webpack-plugin) to minimize JS bundles
|
|
9
|
+
`startup` configures webpack to minimize production bundles, using
|
|
10
|
+
[TerserWebpackPlugin](https://webpack.js.org/plugins/terser-webpack-plugin) for JS bundles
|
|
13
11
|
and [CssMinimizerWebpackPlugin](https://webpack.js.org/plugins/css-minimizer-webpack-plugin)
|
|
14
|
-
|
|
12
|
+
for CSS bundles.
|
|
13
|
+
|
|
14
|
+
For application bundles, `startup` minimizes bundles conservatively, so that projects
|
|
15
|
+
gain the benefits of reduced bundle sizes while retaining the highest fidelity for
|
|
16
|
+
source map debugging.
|
|
17
|
+
|
|
18
|
+
(✨ New in **v37.0.0** ✨) For MFE bundles, `startup` enables Terser's `compress` and `mangle` passes to produce
|
|
19
|
+
the smallest output, relying on [source maps uploaded to Datadog](../mfe-publish#sourcemaps)
|
|
20
|
+
to map runtime errors back to source.
|
|
15
21
|
|
|
16
22
|
- To turn off minimizing, set `cli.webpack.minify.js` or `cli.webpack.minify.css`, or both, to `false`.
|
|
17
23
|
- To override the default Terser options set `cli.webpack.minify.js` to an object containing
|
|
@@ -106,12 +112,16 @@ Don't call `createWebpackConfig` and just return an object with the same `config
|
|
|
106
112
|
E.g.,
|
|
107
113
|
|
|
108
114
|
```js title="webpack.dev.config.js"
|
|
109
|
-
const path = require('path');
|
|
110
|
-
|
|
111
115
|
module.exports = {
|
|
112
116
|
configuration: {
|
|
113
117
|
mode: 'development',
|
|
114
|
-
|
|
118
|
+
devServer: {
|
|
119
|
+
allowedHosts: 'all',
|
|
120
|
+
},
|
|
115
121
|
},
|
|
116
122
|
};
|
|
117
123
|
```
|
|
124
|
+
|
|
125
|
+
:::note
|
|
126
|
+
A custom `output.path` is not honored for MFEs. Their bundles must reside in `dist/bundle/<subdir>` so the host loader can resolve them.
|
|
127
|
+
:::
|
package/docs/startup/clean.mdx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: clean
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Resets project
|
|
5
|
+
Resets project to a fresh state by clearing build caches and removing untracked files.
|
|
6
6
|
|
|
7
7
|
It runs tools like `nx reset` and `jest --clearCache` to clear project and test
|
|
8
8
|
caches, clears the package manager and npx caches, and then uses `git clean -fdX` to delete
|
package/docs/startup/lint.mdx
CHANGED
|
@@ -45,5 +45,5 @@ Use `cli.lint` to set or override `ESLint` and `Stylelint` options. E.g,
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
:::caution
|
|
48
|
-
Because `lint` is a global command that runs from the
|
|
48
|
+
Because `lint` is a global command that runs from the project root, `ESLint` and `Stylelint` configurations must be in the project's root `package.json`.
|
|
49
49
|
:::
|
|
@@ -10,7 +10,7 @@ Use `mfe-list` to see what MFE versions were published and when.
|
|
|
10
10
|
npx startup mfe-list
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
It outputs, for each MFE in the current
|
|
13
|
+
It outputs, for each MFE in the current project,
|
|
14
14
|
|
|
15
15
|
- The MFE's name, current version, and total number of versions
|
|
16
16
|
- A table listing the 20 most recently published versions, with the following columns:
|
|
@@ -58,7 +58,7 @@ npx startup mfe-list @servicetitan/dispatch-center --tagged
|
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
:::tip
|
|
61
|
-
Use this syntax to list any MFE, not just the ones in the project
|
|
61
|
+
Use this syntax to list any MFE, not just the ones in the project.
|
|
62
62
|
:::
|
|
63
63
|
|
|
64
64
|
## Authorization
|
package/docs/startup/review.mdx
CHANGED
|
@@ -3,7 +3,7 @@ title: review
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
The `startup review` command is a static analysis tool for monorepos using `@servicetitan/startup`.
|
|
6
|
-
It checks your
|
|
6
|
+
It checks your project for common configuration and dependency issues using a set of pluggable rules.
|
|
7
7
|
This helps maintain consistency, avoid dependency hell, and enforce best practices across all packages in your repository.
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
@@ -12,14 +12,14 @@ This helps maintain consistency, avoid dependency hell, and enforce best practic
|
|
|
12
12
|
npx startup review
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
- Run from the root of your
|
|
16
|
-
- The command will scan all packages (as defined by your
|
|
15
|
+
- Run from the root of your project (where your root `package.json` and lock file are located).
|
|
16
|
+
- The command will scan all packages (as defined by your project configuration) and report any errors or warnings found by the enabled rules.
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## How It Works
|
|
21
21
|
|
|
22
|
-
1. **Workspace Discovery**: Finds all packages in your monorepo using your
|
|
22
|
+
1. **Workspace Discovery**: Finds all packages in your monorepo using your project configuration.
|
|
23
23
|
2. **Dependency Analysis**: Builds a dependency graph and collects all installed versions from the lock file (`package-lock.json` or `pnpm-lock.yaml`).
|
|
24
24
|
3. **Rule Execution**: Runs each enabled rule against your project and packages.
|
|
25
25
|
4. **Reporting**: Outputs a summary of all problems found, grouped by file and severity.
|
|
@@ -36,7 +36,7 @@ npx startup review
|
|
|
36
36
|
|
|
37
37
|
## Troubleshooting
|
|
38
38
|
|
|
39
|
-
- Make sure you run the command from the
|
|
39
|
+
- Make sure you run the command from the project root.
|
|
40
40
|
- If you see unexpected results, check your configuration and ensure your lock file is up to date.
|
|
41
41
|
|
|
42
42
|
---
|
|
@@ -234,7 +234,7 @@ npm pkg delete dependencies["react"] -w packages/lib
|
|
|
234
234
|
|
|
235
235
|
Enforces open‑ended peer dependency ranges so consumers can choose compatible versions.
|
|
236
236
|
|
|
237
|
-
Closed‑ended ranges like `^1.2.3` or `~1.2.3` are discouraged for peer dependencies because they limit consumers' ability to resolve a single compatible version across a
|
|
237
|
+
Closed‑ended ranges like `^1.2.3` or `~1.2.3` are discouraged for peer dependencies because they limit consumers' ability to resolve a single compatible version across a project. Closed-ended ranges should only be used when there is a known incompatibility with a later version.
|
|
238
238
|
|
|
239
239
|
#### ✅ Autofix
|
|
240
240
|
|
|
@@ -382,6 +382,31 @@ This rule supports autofix. It updates dependencies on `launchdarkly-js-client-s
|
|
|
382
382
|
|
|
383
383
|
---
|
|
384
384
|
|
|
385
|
+
### require-compatible-typescript
|
|
386
|
+
|
|
387
|
+
Ensures the project's resolved `typescript` version is not older than the version required by `@servicetitan/startup`.
|
|
388
|
+
|
|
389
|
+
`@servicetitan/startup` compiles and type-checks your code with its own `typescript` dependency. If the project resolves an older top-level `typescript`, builds and editor type-checking can disagree with `startup`, producing errors that don't reproduce in CI or misleading type results.
|
|
390
|
+
|
|
391
|
+
:::note
|
|
392
|
+
This rule is skipped for `pnpm` projects.
|
|
393
|
+
:::
|
|
394
|
+
|
|
395
|
+
#### ✅ Autofix
|
|
396
|
+
|
|
397
|
+
This rule supports autofix.
|
|
398
|
+
It bumps the resolved `typescript` in the lock file to the version required by `@servicetitan/startup`, without adding `typescript` as a direct dependency.
|
|
399
|
+
|
|
400
|
+
It runs
|
|
401
|
+
|
|
402
|
+
```sh
|
|
403
|
+
npm pkg set dependencies["typescript"]="<required-version>"
|
|
404
|
+
npx @servicetitan/install --fix --quiet
|
|
405
|
+
npm pkg delete dependencies["typescript"]
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
385
410
|
### require-explicit-side-effects
|
|
386
411
|
|
|
387
412
|
Warns if a package is missing the `sideEffects` property in its `package.json`.
|
|
@@ -447,7 +472,7 @@ npm config set --location=project legacy-peer-deps=true
|
|
|
447
472
|
|
|
448
473
|
### require-one-anvil-uikit-contrib-version
|
|
449
474
|
|
|
450
|
-
Ensures the same version of related `anvil-uikit-contrib` packages is installed across the
|
|
475
|
+
Ensures the same version of related `anvil-uikit-contrib` packages is installed across the project.
|
|
451
476
|
|
|
452
477
|
Different versions of related `anvil-uikit-contrib` packages may have breaking changes or incompatible APIs. If some packages use an older version while others use a newer one, you may encounter runtime errors, unexpected behavior, or subtle bugs that are difficult to diagnose.
|
|
453
478
|
|
|
@@ -484,7 +509,7 @@ It sets the version of each dependency to the [highest](#highest-versions) of th
|
|
|
484
509
|
|
|
485
510
|
### require-one-react-version
|
|
486
511
|
|
|
487
|
-
Ensures the same version of `react` and `react-dom` is used across the
|
|
512
|
+
Ensures the same version of `react` and `react-dom` is used across the project.
|
|
488
513
|
|
|
489
514
|
These two packages are fundamentally designed to work together, with `react-dom` relying heavily on the internal structures and mechanisms exposed by `react`.
|
|
490
515
|
|
|
@@ -500,7 +525,7 @@ If multiple versions tie for the most common, it uses the [highest](#highest-ver
|
|
|
500
525
|
|
|
501
526
|
### require-one-uikit-version
|
|
502
527
|
|
|
503
|
-
Ensures the same version of related `uikit` packages is installed across the
|
|
528
|
+
Ensures the same version of related `uikit` packages is installed across the project.
|
|
504
529
|
|
|
505
530
|
Different versions of related `uikit` packages may have breaking changes or incompatible APIs. If some packages use an older version while others use a newer one, you may encounter runtime errors, unexpected behavior, or subtle bugs that are difficult to diagnose.
|
|
506
531
|
|
|
@@ -562,9 +587,9 @@ To manually hoist packages to the root `node_modules`:
|
|
|
562
587
|
|
|
563
588
|
### require-tsconfig-references
|
|
564
589
|
|
|
565
|
-
Ensures that TypeScript project references are configured for all local
|
|
590
|
+
Ensures that TypeScript project references are configured for all local project dependencies.
|
|
566
591
|
|
|
567
|
-
When a package depends on another package in the
|
|
592
|
+
When a package depends on another package in the project, the `tsconfig.json` (and any config that extends it, such as `tsconfig.build.json`) should include a reference to that dependency's tsconfig. This enables incremental builds and ensures proper type checking across package boundaries.
|
|
568
593
|
|
|
569
594
|
#### ✅ Autofix
|
|
570
595
|
|
|
@@ -4,7 +4,7 @@ title: start
|
|
|
4
4
|
|
|
5
5
|
Serves applications and [MFEs](../../microfrontends) during development, watches source files, and automatically reloads pages on changes.
|
|
6
6
|
|
|
7
|
-
`startup` supports two bundlers for development: [Webpack](./webpack) (default) and [Vite](./vite) (opt-in via `--
|
|
7
|
+
`startup` supports two bundlers for development: [Webpack](./webpack) (default) and [Vite](./vite) (opt-in via `--bundler=vite`).
|
|
8
8
|
|
|
9
9
|
:::tip
|
|
10
10
|
To serve an application without `start`, [build](../build) it, then point any static http server to the output **bundle** directory, where the browser will find `index.html`. For example, to serve with [`http-server`](https://www.npmjs.com/package/http-server)
|
|
@@ -17,13 +17,13 @@ npx -yes http-server packages/application/dist/bundle
|
|
|
17
17
|
|
|
18
18
|
## Options
|
|
19
19
|
|
|
20
|
-
| Option
|
|
21
|
-
|
|
|
22
|
-
| `--scope <glob>`
|
|
23
|
-
| `--ignore <glob>`
|
|
24
|
-
| `--code-coverage`
|
|
25
|
-
| `--use-tsc`
|
|
26
|
-
| `--
|
|
20
|
+
| Option | Webpack | Vite | Description |
|
|
21
|
+
| :----------------- | :------ | :--- | :--------------------------------------------------------------------- |
|
|
22
|
+
| `--scope <glob>` | Yes | Yes | Include only packages with names matching the given glob. |
|
|
23
|
+
| `--ignore <glob>` | Yes | Yes | Exclude packages with names matching the given glob. |
|
|
24
|
+
| `--code-coverage` | Yes | Yes | Add instrumentation to bundled code in order to collect code coverage. |
|
|
25
|
+
| `--use-tsc` | Yes | Yes | Use TSC for TypeScript compilation. |
|
|
26
|
+
| `--bundler <name>` | Yes | Yes | Select the bundler: `vite` or `webpack` (default). |
|
|
27
27
|
|
|
28
28
|
## Start Steps
|
|
29
29
|
|
|
@@ -2,14 +2,26 @@
|
|
|
2
2
|
title: Vite
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
✨ New in **
|
|
5
|
+
✨ New in **v37.0.0** ✨
|
|
6
6
|
|
|
7
|
-
Vite is an alternative dev server for `startup start`, enabled with
|
|
7
|
+
Vite is an alternative dev server for `startup start`, enabled with `--bundler=vite`.
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npx startup start --
|
|
10
|
+
npx startup start --bundler=vite
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
To make Vite the default, set `cli.bundler` in the project's root `package.json`:
|
|
14
|
+
|
|
15
|
+
```json title="package.json"
|
|
16
|
+
{
|
|
17
|
+
"cli": {
|
|
18
|
+
"bundler": "vite"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The `--bundler` flag overrides it per invocation.
|
|
24
|
+
|
|
13
25
|
:::tip
|
|
14
26
|
For build-time configuration (minification, plugin overrides, custom templates), see [Vite build](../build/vite).
|
|
15
27
|
:::
|
|
@@ -76,15 +88,22 @@ export default defineConfig({
|
|
|
76
88
|
|
|
77
89
|
See [Vite server.proxy](https://vite.dev/config/server-options#server-proxy) for the full list of options.
|
|
78
90
|
|
|
79
|
-
|
|
91
|
+
### Disabling the dev server
|
|
80
92
|
|
|
81
|
-
Vite
|
|
93
|
+
Set `cli.vite.devServer` to `false` to run `startup start` without an HTTP dev server. Vite instead builds in watch mode, recompiling to the output directory on every change, so a separate server can serve the files from disk.
|
|
82
94
|
|
|
83
|
-
|
|
95
|
+
```json title="package.json"
|
|
96
|
+
{
|
|
97
|
+
"cli": {
|
|
98
|
+
"vite": {
|
|
99
|
+
"devServer": false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
84
104
|
|
|
85
|
-
##
|
|
105
|
+
## Hot Module Replacement
|
|
86
106
|
|
|
87
|
-
|
|
107
|
+
Vite provides fast HMR out of the box. CSS changes are applied instantly without a full page reload.
|
|
88
108
|
|
|
89
|
-
|
|
90
|
-
- `cli.webpack.devServer: false` equivalent: disabling the dev server to use file watching + rebuild to disk instead.
|
|
109
|
+
For MFEs running in shadow DOM, CSS HMR uses `adoptedStyleSheets`. Style updates are applied to the shadow root automatically without affecting the host page.
|
|
@@ -34,6 +34,16 @@ Use `cli.webpack.devServer` to set or override `webpack-dev-server` options.
|
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
### Disabling the dev server
|
|
38
|
+
|
|
39
|
+
Set `cli.webpack.devServer` to `false` to run `startup start` without an HTTP dev server. Webpack instead builds in watch mode, recompiling to the output directory on every change, so a separate server can serve the files from disk.
|
|
40
|
+
|
|
41
|
+
```json title="package.json"
|
|
42
|
+
{
|
|
43
|
+
"cli": {
|
|
44
|
+
"webpack": {
|
|
45
|
+
"devServer": false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
package/docs/startup/startup.mdx
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
title: Startup
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
import Tabs from '@theme/Tabs';
|
|
6
|
-
import TabItem from '@theme/TabItem';
|
|
7
|
-
|
|
8
5
|
#### [CHANGELOG (@servicetitan/startup)](https://github.com/servicetitan/uikit/blob/master/packages/startup/CHANGELOG.md)
|
|
9
6
|
|
|
10
7
|
[@servicetitan/startup](https://github.com/servicetitan/uikit/tree/master/packages/startup) is a command-line interface (CLI) to create multi-package Lerna projects with the support of TypeScript Project References and React. It offers a modern build setup with no configuration.
|
|
@@ -27,8 +24,8 @@ Updating build tooling is typically a daunting and time-consuming task. When new
|
|
|
27
24
|
|
|
28
25
|
`startup` supports two bundlers:
|
|
29
26
|
|
|
30
|
-
- **Webpack
|
|
31
|
-
- **Vite**
|
|
27
|
+
- **Webpack**: the default bundler.
|
|
28
|
+
- **Vite** (✨ New in **v37.0.0** ✨): opt-in via `--bundler=vite` or `cli.bundler` in project's root `package.json`.
|
|
32
29
|
|
|
33
30
|
See [build](./build) and [start](./start) for bundler-specific configuration.
|
|
34
31
|
|
|
@@ -89,14 +86,7 @@ Use `cli.NODE_OPTIONS` or `cli.*.NODE_OPTIONS` to set or override Node options f
|
|
|
89
86
|
|
|
90
87
|
`@servicetitan/startup` provides utility functions to configure Storybook 10 or later with the same build settings used by the [build](./build) and [start](./start) commands.
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
defaultValue="webpack"
|
|
94
|
-
values={[
|
|
95
|
-
{ label: 'Webpack', value: 'webpack' },
|
|
96
|
-
{ label: 'Vite', value: 'vite' },
|
|
97
|
-
]}
|
|
98
|
-
>
|
|
99
|
-
<TabItem value="webpack">
|
|
89
|
+
### Webpack
|
|
100
90
|
|
|
101
91
|
Import `webpackFinal` and `swc` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
|
|
102
92
|
|
|
@@ -143,23 +133,64 @@ export default config;
|
|
|
143
133
|
|
|
144
134
|
For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build/webpack#createwebpackconfig) section in the build documentation.
|
|
145
135
|
|
|
146
|
-
|
|
147
|
-
<TabItem value="vite">
|
|
136
|
+
### Vite
|
|
148
137
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
✨ New in **v37.0.0** ✨
|
|
139
|
+
|
|
140
|
+
Import `viteFinal` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
|
|
141
|
+
|
|
142
|
+
```ts title=".storybook/main.ts"
|
|
143
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
144
|
+
import { createRequire } from 'node:module';
|
|
145
|
+
|
|
146
|
+
const require = createRequire(import.meta.url);
|
|
147
|
+
const { viteFinal } = require('@servicetitan/startup/storybook-config');
|
|
148
|
+
|
|
149
|
+
const config: StorybookConfig = {
|
|
150
|
+
framework: '@storybook/react-vite',
|
|
151
|
+
stories: ['../**/*.stories.ts?(x)'],
|
|
152
|
+
viteFinal,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`viteFinal` applies startup's CSS modules, Less, and SVG configuration to Storybook's resolved Vite config so stories render the same way as your production build. It also pre-bundles and dedupes React so the preview loads a single React instance in a monorepo.
|
|
152
159
|
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
#### Custom configuration
|
|
161
|
+
|
|
162
|
+
To add your own Vite options, wrap `viteFinal` and merge the result:
|
|
163
|
+
|
|
164
|
+
```ts title=".storybook/main.ts"
|
|
165
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
166
|
+
import { createRequire } from 'node:module';
|
|
167
|
+
import { mergeConfig } from 'vite';
|
|
168
|
+
|
|
169
|
+
const require = createRequire(import.meta.url);
|
|
170
|
+
const { viteFinal } = require('@servicetitan/startup/storybook-config');
|
|
171
|
+
|
|
172
|
+
const config: StorybookConfig = {
|
|
173
|
+
framework: '@storybook/react-vite',
|
|
174
|
+
stories: ['../src/**/*.stories.ts?(x)'],
|
|
175
|
+
viteFinal: (config, options) =>
|
|
176
|
+
mergeConfig(viteFinal(config, options), {
|
|
177
|
+
/* Custom Vite config */
|
|
178
|
+
}),
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export default config;
|
|
182
|
+
```
|
|
155
183
|
|
|
156
184
|
## Cypress Component Testing Configuration
|
|
157
185
|
|
|
158
|
-
|
|
186
|
+
`@servicetitan/startup` provides utility functions to configure Cypress for component testing with the same settings used by the [build](./build) and [start](./start) commands.
|
|
187
|
+
This ensures your Cypress component tests run with the same transpilation and module resolution rules as your application code.
|
|
188
|
+
|
|
189
|
+
### Webpack
|
|
159
190
|
|
|
160
|
-
|
|
191
|
+
✨ New in **v35.1.0** ✨
|
|
161
192
|
|
|
162
|
-
|
|
193
|
+
Import `webpackConfig` from `@servicetitan/startup/cypress-config` in your Cypress configuration:
|
|
163
194
|
|
|
164
195
|
```ts title="cypress.config.ts"
|
|
165
196
|
import { defineConfig } from 'cypress';
|
|
@@ -176,8 +207,6 @@ export default defineConfig({
|
|
|
176
207
|
});
|
|
177
208
|
```
|
|
178
209
|
|
|
179
|
-
### Custom overrides
|
|
180
|
-
|
|
181
210
|
You can also pass custom webpack overrides to `webpackConfig`:
|
|
182
211
|
|
|
183
212
|
```ts title="cypress.config.ts"
|
|
@@ -197,7 +226,47 @@ export default defineConfig({
|
|
|
197
226
|
});
|
|
198
227
|
```
|
|
199
228
|
|
|
200
|
-
For details about the structure and options available in webpack overrides, see
|
|
229
|
+
For details about the structure and options available in webpack overrides, see [createWebpackConfig](./build/webpack#createwebpackconfig).
|
|
230
|
+
|
|
231
|
+
### Vite
|
|
232
|
+
|
|
233
|
+
✨ New in **v37.0.0** ✨
|
|
234
|
+
|
|
235
|
+
For projects building with Vite, import `viteConfig` from `@servicetitan/startup/cypress-config` and set `bundler: 'vite'`.
|
|
236
|
+
|
|
237
|
+
```ts title="cypress.config.ts"
|
|
238
|
+
import { defineConfig } from 'cypress';
|
|
239
|
+
import { viteConfig } from '@servicetitan/startup/cypress-config';
|
|
240
|
+
|
|
241
|
+
export default defineConfig({
|
|
242
|
+
component: {
|
|
243
|
+
devServer: {
|
|
244
|
+
framework: 'react',
|
|
245
|
+
bundler: 'vite',
|
|
246
|
+
viteConfig,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Pass an optional Vite `InlineConfig` to merge custom options:
|
|
253
|
+
|
|
254
|
+
```ts title="cypress.config.ts"
|
|
255
|
+
import { defineConfig } from 'cypress';
|
|
256
|
+
import { viteConfig } from '@servicetitan/startup/cypress-config';
|
|
257
|
+
|
|
258
|
+
export default defineConfig({
|
|
259
|
+
component: {
|
|
260
|
+
devServer: {
|
|
261
|
+
framework: 'react',
|
|
262
|
+
bundler: 'vite',
|
|
263
|
+
viteConfig: viteConfig({
|
|
264
|
+
/* Vite InlineConfig overrides */
|
|
265
|
+
}),
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
```
|
|
201
270
|
|
|
202
271
|
### TypeScript Types
|
|
203
272
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
title: Jest
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
`Startup test` uses the Jest by default, with a built-in configuration optimized for ServiceTitan
|
|
5
|
+
`Startup test` uses the Jest by default, with a built-in configuration optimized for ServiceTitan projects.
|
|
6
6
|
|
|
7
7
|
## Configuration
|
|
8
8
|
|
|
9
|
-
You can override the defaults by specifying [Jest options](https://jestjs.io/docs/configuration) in your
|
|
9
|
+
You can override the defaults by specifying [Jest options](https://jestjs.io/docs/configuration) in your project's root `package.json` under the `"cli.jest"` key (the `"cli.test"` key also works, for backward compatibility). For example,
|
|
10
10
|
|
|
11
11
|
```json title="package.json"
|
|
12
12
|
{
|
|
@@ -24,7 +24,7 @@ You can also use a standard Jest config file (such as `jest.config.js`) or pass
|
|
|
24
24
|
|
|
25
25
|
### Package.json
|
|
26
26
|
|
|
27
|
-
Use the
|
|
27
|
+
Use the project's root `package.json` to set up code that runs before each test file is executed:
|
|
28
28
|
|
|
29
29
|
```json title="package.json"
|
|
30
30
|
{
|
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
:::caution
|
|
54
|
-
If your project includes a standard Jest config file and also specifies Jest options in the
|
|
54
|
+
If your project includes a standard Jest config file and also specifies Jest options in the project's root `package.json`, ensure that the configurations are mutually exclusive.
|
|
55
55
|
To avoid confusing or unexpected behavior, do not specify the same setting in both locations.
|
|
56
56
|
:::
|
|
57
57
|
|
|
@@ -5,7 +5,7 @@ title: test
|
|
|
5
5
|
Runs your project's tests.
|
|
6
6
|
|
|
7
7
|
- Supports both Jest and Vitest.
|
|
8
|
-
- Automatically selects the test runner based on your
|
|
8
|
+
- Automatically selects the test runner based on your project's configuration or the `--runner` option.
|
|
9
9
|
- Handles runner-specific arguments and passes them through to the underlying test tool.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -4,7 +4,7 @@ title: Vitest
|
|
|
4
4
|
|
|
5
5
|
✨ New in **v31.6.0** ✨
|
|
6
6
|
|
|
7
|
-
You can change the default test runner from `jest` to `vitest` in
|
|
7
|
+
You can change the default test runner from `jest` to `vitest` in the project's root `package.json`:
|
|
8
8
|
|
|
9
9
|
```json title="package.json"
|
|
10
10
|
{
|
|
@@ -21,18 +21,18 @@ Or, you can override it per invocation with the `--runner` option.
|
|
|
21
21
|
The Vitest runner uses a layered configuration approach to provide sensible defaults while allowing full customization.
|
|
22
22
|
|
|
23
23
|
- Uses the default, built-in configuration as a base.
|
|
24
|
-
- Merges
|
|
24
|
+
- Merges project's settings from the root `package.json`.
|
|
25
25
|
- Merges settings from your Vitest config file.
|
|
26
26
|
- Merges command line options last.
|
|
27
27
|
|
|
28
28
|
1. **Default Configuration:**
|
|
29
|
-
The runner starts with a built-in default configuration optimized for ServiceTitan
|
|
29
|
+
The runner starts with a built-in default configuration optimized for ServiceTitan projects. This includes sensible coverage settings, the environment (`jsdom`), file exclusions, and more.
|
|
30
30
|
|
|
31
31
|
2. **Workspace Configuration:**
|
|
32
|
-
You can customize the configuration by specifying [Vitest options](https://vitest.dev/config) in your
|
|
32
|
+
You can customize the configuration by specifying [Vitest options](https://vitest.dev/config) in your project's root `package.json` under the `"cli.vitest"` key.
|
|
33
33
|
|
|
34
34
|
3. **Vitest Config File:**
|
|
35
|
-
If your project includes a standard Vitest config file (such as `vitest.config.ts` or `vite.config.ts`), its settings will merged with the defaults and
|
|
35
|
+
If your project includes a standard Vitest config file (such as `vitest.config.ts` or `vite.config.ts`), its settings will be merged with the defaults and project's configuration.
|
|
36
36
|
|
|
37
37
|
4. **Command Line Arguments:**
|
|
38
38
|
Any options passed directly via the command line (e.g., `npx startup test --runner vitest --coverage`) take highest precedence over previous configuration layers.
|
|
@@ -41,7 +41,7 @@ The Vitest runner uses a layered configuration approach to provide sensible defa
|
|
|
41
41
|
|
|
42
42
|
### Package.json
|
|
43
43
|
|
|
44
|
-
Use
|
|
44
|
+
Use project's root `package.json` to make `vitest` APIs available [globally](https://vitest.dev/config/#globals) like Jest:
|
|
45
45
|
|
|
46
46
|
```json title="package.json"
|
|
47
47
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-uikit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0",
|
|
4
4
|
"description": "Documentation content for Uikit packages published at docs.st.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"cli": {
|
|
17
17
|
"webpack": false
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "f0acf332ece207c91acb18da23a614efbc8551ec"
|
|
20
20
|
}
|