@servicetitan/docs-uikit 40.3.0 → 41.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.
@@ -3,6 +3,48 @@ title: BREAKING CHANGES
3
3
  sidebar_position: 0
4
4
  ---
5
5
 
6
+ ## v41.0.0
7
+
8
+ ### [@servicetitan/install](./install)
9
+
10
+ - Writes `yes=false` to the project's `.npmrc` in development, in addition to the per-user npm config. Commit the `.npmrc` change so CI `npx` commands fail instead of downloading packages that are not installed.
11
+
12
+ To fix a failing `npx` command, add the package to your project dependencies and run the installed copy. See [npx Confirmation](./install#npx-confirmation).
13
+
14
+ - Writes minimum release age settings to the project's `.npmrc` or `pnpm-workspace.yaml` in development, in addition to per-user npm or global pnpm config. Commit the project config change so CI and other developers get the same protection.
15
+
16
+ npm `11.10.0` through `11.16.x` no longer gets minimum release age protection because those versions do not support release age exclusions. Upgrade npm to `11.17.0` or later, or configure `min-release-age` yourself.
17
+
18
+ To opt out, configure `min-release-age`/`minimumReleaseAge` directly in your project. See [Minimum Release Age](./install#minimum-release-age).
19
+
20
+ ### [@servicetitan/startup](./startup/)
21
+
22
+ - Removed the `mfe-check` and `mfe-generate-metadata` commands. Running them now exits with an error. Use the standalone [@servicetitan/mfe-check](./mfe-check) package instead. Its `generate-metadata` and `check` subcommands take the same options without installing startup's dependencies:
23
+
24
+ ```sh
25
+ npx --yes @servicetitan/mfe-check generate-metadata --output metadata.json
26
+ npx --yes @servicetitan/mfe-check check --metadata metadata.json --host-package-json package.json
27
+ ```
28
+
29
+ - Upgraded Vitest from v4 to v5, which changes defaults (such as `clearMocks`), turns several warnings into errors (such as nested `vi.mock` calls and unawaited `.resolves`/`.rejects` assertions), and moves reporter output to `.vitest/`.
30
+
31
+ `startup review`'s `require-compatible-vitest` fails for any project that resolves an incompatible version of `vitest` or one of the `@vitest/*` packages that must match it. Run `npx startup review --fix` to update them. See [require-compatible-vitest](./startup/review#require-compatible-vitest) for the packages it checks.
32
+
33
+ Projects that use `@storybook/addon-vitest` must upgrade it to `10.6.1` or later, the first version whose peer dependencies allow Vitest 5.
34
+
35
+ See the [Vitest 5 upgrade guide](https://docs.st.dev/docs/frontend/upgrading-to-vitest-5) for the breaking changes and the `migrating-to-vitest-5` skill that automates the mechanical fixes.
36
+
37
+ - Added the `require-npx-confirmation` review rule, enabled by default at `error` severity. Projects whose `.npmrc` does not set `yes=false` will now fail `startup review`.
38
+
39
+ Run `npx startup review --fix` to set it automatically, or set the rule to `"warn"` or `"off"` in `package.json`. See [require-npx-confirmation](./startup/review#require-npx-confirmation).
40
+
41
+ - Upgraded Stylelint to v18. Stylelint configs fail if they reference plugins or configs by paths without a file extension, use removed rules or options, or use plugins that read `context.fix`. See the [Stylelint 18 migration guide](https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-18.md).
42
+
43
+ ### [@servicetitan/stylelint-config](./eslint-config#stylelint)
44
+
45
+ - Extends `stylelint-config-standard` v41, which turns on five new rules that can report new errors. See [the new rules](https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-18.md#added-value-no-invalid-rule).
46
+ - `declaration-property-value-no-unknown` now checks the values that `var()` refers to in CSS files. See [the rule change](https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-18.md#fixed-declaration-property-value-no-unknown-false-negatives-for-values-containing-custom-properties).
47
+
6
48
  ## v40.0.0
7
49
 
8
50
  ### [@servicetitan/install](./install)
@@ -94,6 +94,7 @@ Shared uikit skills for ServiceTitan repos.
94
94
  | `fix-cancelable-requests` | Find and fix Axios call sites that don't handle cancellation errors, in repos that use `initAjaxHandlers` from `@servicetitan/ajax-handlers` |
95
95
  | `migrating-to-npm-trusted-publishing` | Migrate a GitHub Actions publish workflow to npm trusted publishing (OIDC), or troubleshoot OIDC publish failures (see [migration guide](/docs/frontend/npm#github-actions)) |
96
96
  | `migrating-to-typescript-6` | Apply the mechanical TypeScript 6 fixes after upgrading to `@servicetitan/startup` >= 37.0.0, and report remaining type errors for manual resolution |
97
+ | `migrating-to-vitest-5` | Align vitest packages and apply the mechanical Vitest 5 fixes after upgrading to `@servicetitan/startup` >= 41.0.0, and report behavior changes for manual resolution |
97
98
  | `running-startup-commands` | Run tests, lint, and builds via the `startup` CLI in projects that depend on `@servicetitan/startup` |
98
99
  | `spell-check` | Check for spelling errors in code changes |
99
100
  | `switching-to-pnpm` | Migrate a project from npm to pnpm (see [migration guide](/docs/frontend/switching-to-pnpm)) |
@@ -32,10 +32,11 @@ try {
32
32
 
33
33
  ## Options {#options}
34
34
 
35
- | Name | Type | Description |
36
- | :------------ | :------------ | :---------------------------------------------------------------------------------------------------------------------------------------- |
37
- | `baseURL` | `string` | (optional) Base URL of the microservice BFF, used to build the default `authURL`. Defaults to the page's origin |
38
- | `authURL` | `string` | (optional) Silent login URL. Defaults to `${baseURL}/bff/silent-login` |
39
- | `authInfoURL` | `string` | (optional) URL to fetch the user's session information from. Defaults to `/bff/authInfo` on the page's origin, even when `baseURL` is set |
40
- | `timeout` | `number` | (optional) Milliseconds to wait for the iframe to respond. Defaults to `60000` |
41
- | `signal` | `AbortSignal` | (optional) Cancels the silent login |
35
+ | Name | Type | Description |
36
+ | :-------------- | :------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37
+ | `baseURL` | `string` | (optional) Base URL of the microservice BFF, used to build the default `authURL`. Defaults to the page's origin |
38
+ | `authURL` | `string` | (optional) Silent login URL. Defaults to `${baseURL}/bff/silent-login` |
39
+ | `parametersURL` | `string` | (optional) URL to fetch the silent login parameters from. Defaults to `/bff/silent-login-parameters` on the page's origin, even when `baseURL` is set |
40
+ | `authInfoURL` | `string` | (optional) URL to fetch the user's session information from when `parametersURL` doesn't return a valid response. Defaults to `/bff/authInfo` on the page's origin, even when `baseURL` is set |
41
+ | `timeout` | `number` | (optional) Milliseconds to wait for the iframe to respond. Defaults to `60000` |
42
+ | `signal` | `AbortSignal` | (optional) Cancels the silent login |
@@ -187,10 +187,11 @@ const App = withMicroservice({
187
187
 
188
188
  #### TokenServerAuthOptions
189
189
 
190
- | Name | Type | Description |
191
- | :------------ | :--------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------- |
192
- | `authInfoURL` | `string` | (optional) URL to fetch authentication parameters from. Defaults to `'/bff/authinfo'`. |
193
- | `onError` | `(defaultErrorHandler: () => void, error: Error) => void;` | (optional) Callback to call when an error occurs during authentication. Defaults to reloading the page a maximum of 1 time. |
190
+ | Name | Type | Description |
191
+ | :-------------- | :--------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------ |
192
+ | `parametersURL` | `string` | (optional) URL to fetch silent login parameters from. Defaults to `'/bff/silent-login-parameters'`. |
193
+ | `authInfoURL` | `string` | (optional) URL to fetch authentication parameters from when `parametersURL` doesn't return a valid response. Defaults to `'/bff/authInfo'`. |
194
+ | `onError` | `(defaultErrorHandler: () => void, error: Error) => void;` | (optional) Callback to call when an error occurs during authentication. Defaults to reloading the page a maximum of 1 time. |
194
195
 
195
196
  The `onError` callback is passed the following arguments:
196
197
 
@@ -48,6 +48,8 @@ const Root = () => {
48
48
  `hashRouting` requires `trackViewsManually: true` in the [`application`](./init.mdx#applicationconfig) config. Otherwise the SDK also starts a view for each URL change, and RUM records each route twice.
49
49
  :::
50
50
 
51
+ With `react-router-dom` v5, `hashRouting` starts each view as soon as the router navigates, before the page renders, so the page's first requests count toward its view. With v6 and later, it starts each view after the page renders, but before the page's `componentDidMount` and effects send requests.
52
+
51
53
  ## Parameters
52
54
 
53
55
  | Name | Type | Description |
package/docs/install.mdx CHANGED
@@ -96,21 +96,25 @@ pnpm blocks install scripts by default and emits a "Ignored build scripts" warni
96
96
 
97
97
  ## Minimum Release Age
98
98
 
99
- To reduce exposure to supply-chain attacks, both npm (`>=11.10.0`) and pnpm (`>=10.16.0`) can be configured to require packages to have been published for a minimum number of days before they can be installed. We recommend that projects configure a minimum release age of at least `3` days.
99
+ To reduce exposure to supply-chain attacks, npm and pnpm can require packages to have been published for a minimum number of days before they can be installed. We recommend that projects configure a minimum release age of at least `3` days.
100
100
 
101
101
  ### npm projects
102
102
 
103
- If a project hasn't configured its own [`min-release-age`](https://docs.npmjs.com/cli/v11/using-npm/config#min-release-age), `@servicetitan/install` runs `npm` with `3`-day default (excluding `@servicetitan/*` packages). Once a project configures its own `min-release-age`, `@servicetitan/install` defers to it entirely.
103
+ In development environments, on npm `>=11.17.0`, `@servicetitan/install` sets [`min-release-age`](https://docs.npmjs.com/cli/v11/using-npm/config#min-release-age) to `3` days and `min-release-age-exclude` to `@servicetitan/*` in your project's `.npmrc` and in your per-user configuration, unless each setting is already configured there.
104
104
 
105
- On npm versions older than `11.10.0`, `@servicetitan/install` warns and installs without release age protection:
105
+ Commit the change to `.npmrc`, so CI and other developers get the same protection. In CI, if the project has not configured `min-release-age`, `@servicetitan/install` runs `npm` with a `3`-day default and excludes `@servicetitan/*` packages.
106
+
107
+ On npm versions older than `11.17.0`, `@servicetitan/install` does not write unsupported settings. It warns and installs without release age protection:
106
108
 
107
109
  ```
108
- WARNING: npm 10.9.0 does not support minimum release age protection. Installing without it.
110
+ WARNING: npm 11.16.0 does not support minimum release age exclusions. Installing without minimum release age protection.
109
111
  ```
110
112
 
111
113
  ### pnpm projects
112
114
 
113
- pnpm has no per-invocation flag for minimum release age; it must be configured directly in `pnpm-workspace.yaml`. If the project doesn't configure [`minimumReleaseAge`](https://pnpm.io/settings/dependency-resolution#minimumreleaseage), `@servicetitan/install` warns and installs without release age protection
115
+ In development environments, on pnpm `>=10.16.0`, `@servicetitan/install` sets [`minimumReleaseAge`](https://pnpm.io/settings/dependency-resolution#minimumreleaseage) to `3` days and `minimumReleaseAgeExclude` to `@servicetitan/*` in your project's `pnpm-workspace.yaml` and in your global pnpm configuration. Each setting is added only when it isn't already configured in that location.
116
+
117
+ Commit the change to `pnpm-workspace.yaml`, so CI and other developers get the same protection. In CI, or when automatic configuration is skipped or fails, `@servicetitan/install` warns if pnpm install doesn't see a configured `minimumReleaseAge`. It still runs install, but without release age protection:
114
118
 
115
119
  ```
116
120
  WARNING: this project does not enforce a minimum release age for pnpm installs. Configure minimumReleaseAge in pnpm-workspace.yaml.
@@ -118,20 +122,24 @@ WARNING: this project does not enforce a minimum release age for pnpm installs.
118
122
 
119
123
  ## npx Confirmation
120
124
 
121
- In development environments, `@servicetitan/install` sets npm's [`yes`](https://docs.npmjs.com/cli/v11/using-npm/config#yes) option to `false` in your per-user configuration. With this setting, `npx` refuses to download and run a package that isn't already installed, so a typosquatted or compromised package can't run silently. Instead of silently downloading and running the package, it reports:
125
+ In development environments, `@servicetitan/install` sets npm's [`yes`](https://docs.npmjs.com/cli/v11/using-npm/config#yes) option to `false` in your project's `.npmrc` and in your per-user configuration. It does this for both npm and pnpm projects because `npx` reads npm config.
126
+
127
+ Commit the change to `.npmrc`, so `npx` is also protected in CI. With `yes=false`, `npx` refuses to download and run a package that isn't already installed. Instead of silently downloading and running the package, it reports:
122
128
 
123
129
  ```
124
130
  npx canceled due to missing packages and no YES option: ["some-package@1.2.3"]
125
131
  ```
126
132
 
127
- To confirm that you want to run the package, add `--yes`:
133
+ To fix the failure, add the package to your project's dependencies, so `npx` runs the installed copy.
134
+
135
+ To intentionally download and run a package anyway, add `--yes`:
128
136
 
129
137
  ```sh
130
138
  npx --yes some-package
131
139
  ```
132
140
 
133
141
  :::caution
134
- `@servicetitan/install` only sets the option when it is unset. You can opt out by running `npm config set yes=true --location=user`, but this is dangerous and not recommended.
142
+ `@servicetitan/install` only sets `yes=false` when that setting is unset. You can opt out for your user by running `npm config set yes=true --location=user`, but this is dangerous and not recommended.
135
143
  :::
136
144
 
137
145
  ## Configuring NPM Token in Development
@@ -0,0 +1,168 @@
1
+ ---
2
+ title: MFE Compatibility Check
3
+ ---
4
+
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
8
+ #### [CHANGELOG (@servicetitan/mfe-check)](https://github.com/servicetitan/uikit/blob/master/packages/mfe-check/CHANGELOG.md)
9
+
10
+ `@servicetitan/mfe-check` checks whether an MFE's shared dependencies are compatible with a host application. This determines whether the MFE can use a "light" or "full" bundle (see [Sharing Dependencies](./microfrontends/sharing-dependencies)).
11
+
12
+ It provides two subcommands:
13
+
14
+ - [`generate-metadata`](#generate-metadata) generates the MFE's `metadata.json`
15
+ - [`check`](#check) checks that metadata against the host's `package.json`
16
+
17
+ :::info
18
+ These replace the `startup mfe-generate-metadata` and `startup mfe-check` commands.
19
+ :::
20
+
21
+ ## generate-metadata
22
+
23
+ Generates a `metadata.json` file containing the MFE's shared dependencies, bundled versions, and entrypoints. Run it from the MFE's package directory:
24
+
25
+ ```sh
26
+ npx --yes @servicetitan/mfe-check generate-metadata --output metadata.json
27
+ ```
28
+
29
+ | Option | Description |
30
+ | :--------- | :----------------------------------------------------------------- |
31
+ | `--output` | Output file path. If not specified, metadata is written to stdout. |
32
+
33
+ ## check
34
+
35
+ Checks the MFE's metadata against the host.
36
+
37
+ :::caution
38
+ The host must be configured to [provide shared dependencies](./microfrontends/hosting#configuration) else `check` exits with an error.
39
+ :::
40
+
41
+ | Option | Description |
42
+ | :-------------------- | :----------------------------------------------------------------------------------------------------- |
43
+ | `--metadata` | Path to MFE's `metadata.json` file, generated by [`generate-metadata`](#generate-metadata) (required). |
44
+ | `--host-package-json` | Path to host `package.json` file (required). Can be specified multiple times. |
45
+ | `--json` | Output results as JSON instead of human-readable format. Default: `false`. |
46
+
47
+ <Tabs>
48
+ <TabItem value="basic" label="Basic" default>
49
+
50
+ ```sh
51
+ npx --yes @servicetitan/mfe-check check \
52
+ --metadata path/to/mfe/metadata.json \
53
+ --host-package-json path/to/host/package.json
54
+ ```
55
+
56
+ </TabItem>
57
+ <TabItem value="monorepo" label="Monorepo">
58
+
59
+ For monorepos with dependencies split across multiple `package.json` files, specify each one:
60
+
61
+ ```sh
62
+ npx --yes @servicetitan/mfe-check check \
63
+ --metadata path/to/mfe/metadata.json \
64
+ --host-package-json path/to/host/app/package.json \
65
+ --host-package-json path/to/host/root/package.json
66
+ ```
67
+
68
+ :::caution
69
+ The first `--host-package-json` must be the host package's own `package.json`. This is the file from which the command reads the [`provide-shared-dependencies`](./microfrontends/hosting#configuration) (and [`shared-dependencies`](./microfrontends/sharing-dependencies)) configuration. Dependencies are merged from all specified files, with the first file's versions taking precedence.
70
+ :::
71
+
72
+ </TabItem>
73
+
74
+ </Tabs>
75
+
76
+ When the MFE and host have compatible dependencies, `check` exits with a zero status code. If they are incompatible, or there is an unexpected error, it exits with a non-zero status code.
77
+
78
+ ### Output
79
+
80
+ <Tabs groupId="check-output">
81
+ <TabItem value="compatible" label="Compatible" default>
82
+
83
+ When all shared dependencies match, the light bundle of the MFE can be loaded:
84
+
85
+ ```
86
+ Checking @servicetitan/my-mfe...
87
+ Compatible: light bundle can be used
88
+ ```
89
+
90
+ </TabItem>
91
+ <TabItem value="mismatch" label="Version mismatch">
92
+
93
+ When dependency versions don't match, it lists the mismatched dependencies:
94
+
95
+ ```
96
+ Checking @servicetitan/my-mfe...
97
+ Dependency mismatch found:
98
+ react: host=18.2.0, package=^17.0.0
99
+ mobx: host=missing, package=^6.0.0
100
+ Result: full bundle required
101
+ ```
102
+
103
+ </TabItem>
104
+ <TabItem value="shared-dependencies-not-provided" label="Shared dependencies not provided">
105
+
106
+ When the host does not provide shared dependencies, it reports the error:
107
+
108
+ ```
109
+ Checking @servicetitan/my-mfe...
110
+ provide-shared-dependencies is not enabled in host package.json
111
+ Result: full bundle required
112
+ ```
113
+
114
+ </TabItem>
115
+ </Tabs>
116
+
117
+ #### JSON Output
118
+
119
+ <Tabs groupId="check-output">
120
+ <TabItem value="compatible" label="Compatible" default>
121
+
122
+ ```json
123
+ {
124
+ "name": "@servicetitan/my-mfe",
125
+ "compatible": true,
126
+ "bundleType": "light",
127
+ "isSharedDependenciesEnabled": true,
128
+ "isHostMfe": false
129
+ }
130
+ ```
131
+
132
+ </TabItem>
133
+ <TabItem value="mismatch" label="Version mismatch">
134
+
135
+ ```json
136
+ {
137
+ "name": "@servicetitan/my-mfe",
138
+ "compatible": false,
139
+ "bundleType": "full",
140
+ "isSharedDependenciesEnabled": true,
141
+ "isHostMfe": false,
142
+ "mismatches": {
143
+ "react": { "host": "18.2.0", "package": "^17.0.0" },
144
+ "mobx": { "host": "missing", "package": "^6.0.0" }
145
+ }
146
+ }
147
+ ```
148
+
149
+ </TabItem>
150
+ <TabItem value="shared-dependencies-not-provided" label="Shared dependencies not provided">
151
+
152
+ ```json
153
+ {
154
+ "name": "@servicetitan/my-mfe",
155
+ "compatible": false,
156
+ "bundleType": "full",
157
+ "isSharedDependenciesEnabled": false,
158
+ "isHostMfe": false
159
+ }
160
+ ```
161
+
162
+ </TabItem>
163
+ </Tabs>
164
+
165
+ ## See Also
166
+
167
+ - [Sharing Dependencies](./microfrontends/sharing-dependencies) - Learn about shared dependencies
168
+ - [Frontend Example](https://github.com/servicetitan/frontend-example/blob/master/.github/workflows/mfe-check-shared-dependencies-trigger.yml) - Example workflow that automates compatibility check
@@ -6,22 +6,22 @@ A host is an application, or MFE, that uses [`Loader`](../web-components/loader)
6
6
 
7
7
  ## Configuration
8
8
 
9
- Set `cli.expose-shared-dependencies` to `true` in the application's `package.json`.
9
+ Set `cli.provide-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. Setting it on a package marked `cli.web-component` fails the build.
12
+ `provide-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"
16
16
  {
17
17
  "cli": {
18
- "expose-shared-dependencies": true
18
+ "provide-shared-dependencies": true
19
19
  }
20
20
  }
21
21
  ```
22
22
 
23
23
  :::note
24
- In versions before **36.4.0**, this setting was under `cli.webpack.expose-shared-dependencies`. The old location still works for backward compatibility.
24
+ In versions before **40.4.0**, this setting was named `cli.expose-shared-dependencies`, and in versions before **36.4.0** it was under `cli.webpack.expose-shared-dependencies`. The old names still work for backward compatibility, but `startup` logs a deprecation warning. They will be removed in a future major release.
25
25
  :::
26
26
 
27
27
  ### Design system
@@ -30,7 +30,7 @@ MFE's are not required to use all the default dependencies; `startup` and `Loade
30
30
  To customize which dependencies are shared, set `cli.shared-dependencies` to an object that maps dependencies to `SharedDependencies.{name}`. By convention `{name}` is the camel-cased package name.
31
31
 
32
32
  :::note
33
- In versions before **36.4.0**, this setting was under `cli.webpack.shared-dependencies`. The old location still works for backward compatibility.
33
+ In versions before **36.4.0**, this setting was under `cli.webpack.shared-dependencies`. The old location still works for backward compatibility, but `startup` logs a deprecation warning. It will be removed in a future major release.
34
34
  :::
35
35
 
36
36
  - Use the special **defaults** key with the empty string to incorporate the default list.
@@ -104,6 +104,69 @@ import { Provider } from '@servicetitan/react-ioc';
104
104
  | `errorFallback` | `ReactNode` | (optional) Rendered when initialization throws or [duplicate tokens](#runtime-checks) are found. Defaults to `<h2>Error</h2>`. |
105
105
  | `children` | `ReactNode` | The sub-tree that can consume the bindings. |
106
106
 
107
+ #### Bindings are read once at mount {#bindings-read-once}
108
+
109
+ `Provider` reads `singletons` and `instances` once, when it mounts, and binds them to its container. Changes to these props on later renders are ignored. That includes changing a [`useValue`](#entry-shapes): the provided value does not change, and consumers keep getting the value from the first render.
110
+
111
+ ```tsx
112
+ import { Provider, symbolToken } from '@servicetitan/react-ioc';
113
+
114
+ const CONFIG_TOKEN = symbolToken<AppConfig>('APP_CONFIG');
115
+
116
+ // ❌ Consumers keep getting the first `config`, even when the prop changes.
117
+ const App = ({ config }: { config: AppConfig }) => (
118
+ <Provider singletons={[{ provide: CONFIG_TOKEN, useValue: config }]}>
119
+ <Page />
120
+ </Provider>
121
+ );
122
+ ```
123
+
124
+ To pass values that change over time, provide a store and update its observable state instead of replacing the bound value. For example, with a MobX store:
125
+
126
+ ```tsx
127
+ import { Provider, useDependencies } from '@servicetitan/react-ioc';
128
+ import { action, makeObservable, observable } from 'mobx';
129
+ import { observer } from 'mobx-react';
130
+ import { useEffect, useState } from 'react';
131
+
132
+ class ConfigStore {
133
+ @observable.ref config: AppConfig;
134
+
135
+ constructor(config: AppConfig) {
136
+ this.config = config;
137
+ makeObservable(this);
138
+ }
139
+
140
+ @action
141
+ setConfig = (config: AppConfig) => {
142
+ this.config = config;
143
+ };
144
+ }
145
+
146
+ // ✅ The bound store never changes; only its `config` does.
147
+ const App = ({ config }: { config: AppConfig }) => {
148
+ const [configStore] = useState(() => new ConfigStore(config));
149
+
150
+ useEffect(() => {
151
+ configStore.setConfig(config);
152
+ }, [configStore, config]);
153
+
154
+ return (
155
+ <Provider singletons={[{ provide: ConfigStore, useValue: configStore }]}>
156
+ <Page />
157
+ </Provider>
158
+ );
159
+ };
160
+
161
+ // `observer` re-renders the component when `config` changes.
162
+ const Page = observer(() => {
163
+ const [configStore] = useDependencies(ConfigStore);
164
+ return <div>{configStore.config.apiUrl}</div>;
165
+ });
166
+ ```
167
+
168
+ Alternatively, give the `Provider` a new `key` to remount it with the new value. This rebuilds every binding and remounts everything below the `Provider`, so prefer the store approach.
169
+
107
170
  ### `@provide` {#provide}
108
171
 
109
172
  Decorator equivalent of `<Provider>`. Wraps a function or class component.
@@ -178,12 +241,12 @@ const CONFIG_TOKEN = symbolToken<AppConfig>('APP_CONFIG');
178
241
  <Provider singletons={[{ provide: Store }]} />;
179
242
  ```
180
243
 
181
- | Field | Type | Description |
182
- | :--------- | :-------------------- | :---------------------------------------------------------------------------------------------------------------- |
183
- | `provide` | [`Token<T>`](#tokens) | The identifier consumers ask for. |
184
- | `useClass` | `Newable<T>` | (optional) Class to instantiate. If omitted on a class token, `provide` is used as both token and implementation. |
185
- | `useValue` | `T` | (optional) Pre-built value. Cannot be combined with `useClass`. Only valid in `singletons`. |
186
- | `inherit` | `true` | (optional) See [Reusing a parent binding](#inherit). Only valid in `singletons`. |
244
+ | Field | Type | Description |
245
+ | :--------- | :-------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
246
+ | `provide` | [`Token<T>`](#tokens) | The identifier consumers ask for. |
247
+ | `useClass` | `Newable<T>` | (optional) Class to instantiate. If omitted on a class token, `provide` is used as both token and implementation. |
248
+ | `useValue` | `T` | (optional) Pre-built value. Cannot be combined with `useClass`. Only valid in `singletons`. Read once at mount; see [Bindings are read once at mount](#bindings-read-once). |
249
+ | `inherit` | `true` | (optional) See [Reusing a parent binding](#inherit). Only valid in `singletons`. |
187
250
 
188
251
  ### Reusing a parent binding {#inherit}
189
252
 
@@ -56,3 +56,31 @@ Use `cli.lint` to set or override `ESLint` and `Stylelint` options. E.g,
56
56
  :::caution
57
57
  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`.
58
58
  :::
59
+
60
+ ## Ignored files
61
+
62
+ Stylelint ignores `node_modules`, the packages' output folders, and the files listed in `.stylelintignore` in the project root.
63
+
64
+ ✨ New in **v41.0.0** ✨
65
+
66
+ If `.stylelintignore` does not exist, Stylelint ignores the files listed in `.gitignore` instead. `.stylelintignore` takes precedence: when it exists, `.gitignore` is not used. If neither file exists, only `node_modules` and the output folders are ignored.
67
+
68
+ :::info
69
+ Note that only the `.gitignore` in the project root is used. Stylelint does not read `.gitignore` files in subfolders, `.git/info/exclude`, or your global git excludes.
70
+ :::
71
+
72
+ To use both files, set Stylelint's [`ignorePath`](https://stylelint.io/user-guide/options#ignorepath) option. It accepts a path or an array of paths, relative to the project root. The files in an array are combined in order, so a negated pattern (`!pattern`) in a later file can un-ignore a file listed in an earlier one, but not a file inside an ignored folder.
73
+
74
+ ```json title="package.json"
75
+ {
76
+ "cli": {
77
+ "lint": {
78
+ "stylelint": {
79
+ "ignorePath": [".stylelintignore", ".gitignore"]
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ To lint files that are listed in `.gitignore`, add an empty `.stylelintignore`, or set `"ignorePath": ".stylelintignore"`.
@@ -2,149 +2,7 @@
2
2
  title: mfe-check
3
3
  ---
4
4
 
5
- import Tabs from '@theme/Tabs';
6
- import TabItem from '@theme/TabItem';
7
-
8
- Checks MFE/host dependency compatibility.
9
-
10
- Use `mfe-check` to verify that an MFE's shared dependencies are compatible with the host application. This determines whether the MFE can use a "light" or "full" bundle (see [Sharing Dependencies](../microfrontends/sharing-dependencies)).
11
-
12
- :::caution
13
- The host must be configured to [expose shared dependencies](../microfrontends/hosting#configuration) else `mfe-check` exits with an error.
5
+ :::danger
6
+ The `startup mfe-check` command has been removed. Running it now exits with an error pointing to
7
+ [@servicetitan/mfe-check](../mfe-check#check); use that package directly instead.
14
8
  :::
15
-
16
- ## Options
17
-
18
- | Option | Description |
19
- | :-------------------- | :----------------------------------------------------------------------------------------------------------------------------------- |
20
- | `--metadata` | Path to MFE's `metadata.json` file, can be generated with the [`mfe-generate-metadata`](./mfe-generate-metadata) command (required). |
21
- | `--host-package-json` | Path to host `package.json` file (required). Can be specified multiple times. |
22
- | `--json` | Output results as JSON instead of human-readable format. Default: `false`. |
23
-
24
- ## Usage
25
-
26
- <Tabs>
27
- <TabItem value="basic" label="Basic" default>
28
-
29
- Run the `mfe-check` command to check compatibility with an MFE:
30
-
31
- ```sh
32
- npx startup mfe-check \
33
- --metadata path/to/mfe/metadata.json \
34
- --host-package-json path/to/host/package.json
35
- ```
36
-
37
- </TabItem>
38
- <TabItem value="monorepo" label="Monorepo">
39
-
40
- For monorepos with dependencies split across multiple `package.json` files, specify each one:
41
-
42
- ```sh
43
- npx startup mfe-check \
44
- --metadata path/to/mfe/metadata.json \
45
- --host-package-json path/to/host/app/package.json \
46
- --host-package-json path/to/host/root/package.json
47
- ```
48
-
49
- :::caution
50
- The first `--host-package-json` must be the host package's own `package.json`. This is the file from which the command reads the [`expose-shared-dependencies`](../microfrontends/hosting#configuration) (and [`shared-dependencies`](../microfrontends/sharing-dependencies)) configuration. Dependencies are merged from all specified files, with the first file's versions taking precedence.
51
- :::
52
-
53
- </TabItem>
54
-
55
- </Tabs>
56
-
57
- When the MFE and host have compatible dependencies, `mfe-check` exits with a zero status code. If they are incompatible, or there is an unexpected error, it exits with a non-zero status code.
58
-
59
- ## Output
60
-
61
- <Tabs>
62
- <TabItem value="compatible" label="Compatible" default>
63
-
64
- When all shared dependencies match, the light bundle of the MFE can be loaded:
65
-
66
- ```
67
- Checking @servicetitan/my-mfe...
68
- Compatible: light bundle can be used
69
- ```
70
-
71
- </TabItem>
72
- <TabItem value="mismatch" label="Version mismatch">
73
-
74
- When dependency versions don't match, it lists the mismatched dependencies:
75
-
76
- ```
77
- Checking @servicetitan/my-mfe...
78
- Dependency mismatch found:
79
- react: host=18.2.0, package=^17.0.0
80
- mobx: host=missing, package=^6.0.0
81
- Result: full bundle required
82
- ```
83
-
84
- </TabItem>
85
- <TabItem value="shared-dependencies-not-exposed" label="Shared dependencies not exposed">
86
-
87
- When the host does not expose dependencies, it reports the error:
88
-
89
- ```
90
- Checking @servicetitan/my-mfe...
91
- expose-shared-dependencies is not enabled in host package.json
92
- Result: full bundle required
93
- ```
94
-
95
- </TabItem>
96
- </Tabs>
97
-
98
- ### JSON Output
99
-
100
- <Tabs>
101
- <TabItem value="json-compatible" label="Compatible" default>
102
-
103
- ```json
104
- {
105
- "name": "@servicetitan/my-mfe",
106
- "compatible": true,
107
- "bundleType": "light",
108
- "isSharedDependenciesEnabled": true,
109
- "isHostMfe": false
110
- }
111
- ```
112
-
113
- </TabItem>
114
- <TabItem value="json-mismatch" label="Version Mismatch">
115
-
116
- ```json
117
- {
118
- "name": "@servicetitan/my-mfe",
119
- "compatible": false,
120
- "bundleType": "full",
121
- "isSharedDependenciesEnabled": true,
122
- "isHostMfe": false,
123
- "mismatches": {
124
- "react": { "host": "18.2.0", "package": "^17.0.0" },
125
- "mobx": { "host": "missing", "package": "^6.0.0" }
126
- }
127
- }
128
- ```
129
-
130
- </TabItem>
131
- <TabItem value="shared-dependencies-not-exposed" label="Shared dependencies not exposed">
132
-
133
- ```json
134
- {
135
- "name": "@servicetitan/my-mfe",
136
- "compatible": false,
137
- "bundleType": "full",
138
- "isSharedDependenciesEnabled": false,
139
- "isHostMfe": false
140
- }
141
- ```
142
-
143
- </TabItem>
144
- </Tabs>
145
-
146
- ## See Also
147
-
148
- - [`mfe-generate-metadata`](./mfe-generate-metadata) - Generate MFE metadata for compatibility checking
149
- - [Sharing Dependencies](../microfrontends/sharing-dependencies) - Learn about shared dependencies
150
- - [Frontend Example](https://github.com/servicetitan/frontend-example/blob/master/.github/workflows/mfe-check-shared-dependencies-trigger.yml) - Example workflow that automates compatibility check
@@ -2,25 +2,7 @@
2
2
  title: mfe-generate-metadata
3
3
  ---
4
4
 
5
- Generates MFE metadata for compatibility checking.
6
-
7
- Use `mfe-generate-metadata` to produce a `metadata.json` file containing information about the MFE's shared dependencies, bundled versions, and entrypoints. This metadata is used by the [`mfe-check`](./mfe-check) command to check compatibility between an MFE and a host application.
8
-
9
- :::note
10
- This command must be run from within an MFE directory.
5
+ :::danger
6
+ The `startup mfe-generate-metadata` command has been removed. Running it now exits with an error pointing to
7
+ [@servicetitan/mfe-check](../mfe-check#generate-metadata); use that package directly instead.
11
8
  :::
12
-
13
- ```sh
14
- npx startup mfe-generate-metadata --output metadata.json
15
- ```
16
-
17
- ## Options
18
-
19
- | Option | Description |
20
- | :--------- | :----------------------------------------------------------------- |
21
- | `--output` | Output file path. If not specified, metadata is written to stdout. |
22
-
23
- ## See Also
24
-
25
- - [`mfe-check`](./mfe-check) - Check MFE/host dependency compatibility
26
- - [Sharing Dependencies](../microfrontends/sharing-dependencies) - Learn about shared dependencies
@@ -407,6 +407,70 @@ npm pkg delete dependencies["typescript"]
407
407
 
408
408
  ---
409
409
 
410
+ ### require-compatible-vitest
411
+
412
+ Ensures the project's `vitest` packages match the version of `vitest` that `@servicetitan/startup` runs.
413
+
414
+ `startup test --runner vitest` runs tests with `@servicetitan/startup`'s own `vitest` dependency, but test files import `vitest` from the project. Vitest doesn't support running with mismatched versions of its packages, so if the project resolves a different version, tests can fail with confusing errors, or coverage can fail to run.
415
+
416
+ The rule checks `vitest`, `@vitest/coverage-v8`, and the other `@vitest/*` packages that must match it (`@vitest/browser`, `@vitest/browser-playwright`, `@vitest/browser-preview`, `@vitest/coverage-istanbul`, `@vitest/ui`). It reports packages that declare one of them with an incompatible version. If no package does, it reports an incompatible version hoisted to the project's top level.
417
+
418
+ #### ✅ Autofix
419
+
420
+ This rule supports autofix.
421
+
422
+ For a package that declares the dependency, it updates the declared version to the version required by `@servicetitan/startup`.
423
+
424
+ For a hoisted dependency, it bumps the resolved version in the lock file without adding it as a direct dependency. It runs
425
+
426
+ ```sh
427
+ npm pkg set dependencies["<dependency>"]="<required-version>"
428
+ npx @servicetitan/install --fix --quiet
429
+ npm pkg delete dependencies["<dependency>"]
430
+ ```
431
+
432
+ ---
433
+
434
+ ### require-declared-version-in-workspace-node-modules
435
+
436
+ Checks that each package in your project gets the version of each dependency that its `package.json` declares.
437
+
438
+ If a package's own `node_modules` contains a version outside the declared range, the package uses that version, leading to missing exports, changed behavior, or other runtime errors. Vite projects are the most likely to fail, because Vite's dev server serves only one version of each dependency to every package that imports it, and that can be the wrong version.
439
+
440
+ :::note
441
+ This rule is skipped for `pnpm` projects.
442
+ pnpm puts only a package's declared dependencies in its `node_modules`, so this mismatch can't occur.
443
+ :::
444
+
445
+ #### ❌ Autofix
446
+
447
+ This rule is not fixable automatically.
448
+ Run `npm ls <dependency>` to find the package that installs the out-of-range version, then do one of the following:
449
+
450
+ - Upgrade that package to a version that uses the version your package declares.
451
+ - Add an [`overrides`](https://docs.npmjs.com/cli/configuring-npm/package-json#overrides) entry in the root `package.json` that makes that package use the version your package declares, then run `npx @servicetitan/install`.
452
+ First check that it works with that version. For example:
453
+
454
+ ```json title="package.json"
455
+ {
456
+ "overrides": {
457
+ "@servicetitan/onboarding-ui": {
458
+ "@servicetitan/react-hooks": "~7.7.0"
459
+ }
460
+ }
461
+ }
462
+ ```
463
+
464
+ #### ⚙️ Configuration
465
+
466
+ [`exclude`](#exclude) takes dependency names, not workspace package names. For example:
467
+
468
+ ```json
469
+ "require-declared-version-in-workspace-node-modules": ["warn", { "exclude": ["@servicetitan/react-hooks"] }]
470
+ ```
471
+
472
+ ---
473
+
410
474
  ### require-explicit-side-effects
411
475
 
412
476
  Warns if a package is missing the `sideEffects` property in its `package.json`.
@@ -449,12 +513,12 @@ npm pkg set sideEffects=false -w @servicetitan/package
449
513
 
450
514
  ### require-min-release-age
451
515
 
452
- Ensures the project enforces a minimum release age of at least `3` days.
516
+ Ensures the project enforces a minimum release age of at least `3` days. npm projects configure it in `.npmrc` with `min-release-age`. pnpm projects configure it in `pnpm-workspace.yaml` with `minimumReleaseAge`. Settings outside the project, such as in your per-user configuration, don't count.
453
517
 
454
518
  This reduces exposure to supply-chain attacks by giving the community time to detect and take down malicious packages.
455
519
 
456
520
  :::note
457
- This rule is skipped when the project's npm (`<11.10.0`) or pnpm (`<10.16.0`) version doesn't support minimum release age.
521
+ This rule is skipped when the project's npm (`<11.17.0`) or pnpm (`<10.16.0`) version doesn't support minimum release age.
458
522
  :::
459
523
 
460
524
  #### ✅ Autofix
@@ -471,7 +535,7 @@ For pnpm projects, it runs
471
535
  pnpm config set --location=project minimumReleaseAge 4320
472
536
  ```
473
537
 
474
- If no exclusion is already configured, the fix also adds one for `@servicetitan` packages. For npm,
538
+ When fixing a missing or too-low minimum release age, the rule also adds an `@servicetitan` package exclusion if the project doesn't already configure one. For npm,
475
539
 
476
540
  ```sh
477
541
  npm config set --location=project 'min-release-age-exclude=@servicetitan/*'
@@ -512,6 +576,26 @@ npm config set --location=project legacy-peer-deps=true
512
576
 
513
577
  ---
514
578
 
579
+ ### require-npx-confirmation
580
+
581
+ Ensures your project's `.npmrc` sets npm's [`yes`](https://docs.npmjs.com/cli/v11/using-npm/config#yes) option to `false`. The rule applies to both npm and pnpm projects because `npx` reads npm configuration.
582
+
583
+ With `yes=false`, `npx` refuses to run packages that aren't installed. `@servicetitan/install` may also set `yes=false` in a developer's per-user config, but this rule only checks the project config so `npx` is protected in CI. See [npx Confirmation](../install#npx-confirmation).
584
+
585
+ ```text title=".npmrc"
586
+ yes=false
587
+ ```
588
+
589
+ #### ✅ Autofix
590
+
591
+ This rule supports autofix. It runs
592
+
593
+ ```sh
594
+ npm config set --location=project yes=false
595
+ ```
596
+
597
+ ---
598
+
515
599
  ### require-one-anvil-uikit-contrib-version
516
600
 
517
601
  Ensures the same version of related `anvil-uikit-contrib` packages is installed across the project.
@@ -547,6 +631,23 @@ This is important because:
547
631
  This rule supports autofix.
548
632
  It sets the version of each dependency to the [highest](#highest-versions) of the conflicting versions.
549
633
 
634
+ #### ⚙️ Configuration
635
+
636
+ The `exclude` option can be a list of dependencies to omit from the check entirely, or an object that maps packages to the dependencies they may declare at a different version.
637
+
638
+ For example, this configuration allows `@servicetitan/mfe-check` to pin `js-yaml` and `semver` while the rule still checks every other package's versions of them.
639
+
640
+ ```json
641
+ "require-one-package-version": [
642
+ "error",
643
+ {
644
+ "exclude": {
645
+ "@servicetitan/mfe-check": ["js-yaml", "semver"]
646
+ }
647
+ }
648
+ ]
649
+ ```
650
+
550
651
  ---
551
652
 
552
653
  ### require-one-react-version
@@ -42,8 +42,8 @@ Already on webpack and want to switch? See [Migrating to Vite](https://docs.st.d
42
42
  - [install](./install) removed; use `@servicetitan/install` directly
43
43
  - [kendo-ui-license](./kendo-ui-license) install KendoReact license key
44
44
  - [lint](./lint) run eslint and stylelint
45
- - [mfe-check](./mfe-check) check MFE/host dependency compatibility
46
- - [mfe-generate-metadata](./mfe-generate-metadata) generate MFE metadata for compatibility checking
45
+ - [mfe-check](./mfe-check) removed; use `@servicetitan/mfe-check` directly
46
+ - [mfe-generate-metadata](./mfe-generate-metadata) removed; use `@servicetitan/mfe-check` directly
47
47
  - [mfe-list](./mfe-list) list published MFE packages
48
48
  - [mfe-publish](./mfe-publish) publish or unpublish MFE packages
49
49
  - [review](./review) check project for configuration errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/docs-uikit",
3
- "version": "40.3.0",
3
+ "version": "41.0.0",
4
4
  "description": "Documentation content for Uikit packages published at docs.st.dev",
5
5
  "repository": {
6
6
  "type": "git",