Skip to content

Commit 7f2aea6

Browse files
authored
docs(runtime): update typescript definitions of init function (#3357)
1 parent 5ea7aea commit 7f2aea6

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

apps/website-new/docs/en/guide/basic/runtime.mdx

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ type InitOptions = {
8080
shared?: {
8181
[pkgName: string]: ShareArgs | ShareArgs[];
8282
};
83+
// Sharing strategy, which strategy will be used to decide whether to reuse the dependency
84+
shareStrategy?: 'version-first' | 'loaded-first';
8385
};
8486

8587
type ShareArgs =
@@ -91,7 +93,6 @@ type SharedBaseArgs = {
9193
shareConfig?: SharedConfig;
9294
scope?: string | Array<string>;
9395
deps?: Array<string>;
94-
strategy?: 'version-first' | 'loaded-first';
9596
loaded?: boolean;
9697
};
9798

@@ -104,41 +105,11 @@ type RemoteInfo = (RemotesWithEntry | RemotesWithVersion) & {
104105
interface RemotesWithVersion {
105106
name: string;
106107
version: string;
107-
}
108+
};
108109

109110
interface RemotesWithEntry {
110111
name: string;
111112
entry: string;
112-
}
113-
114-
type ShareInfos = {
115-
// The name of the dependency, basic information about the dependency, and sharing strategy
116-
[pkgName: string]: Shared[];
117-
};
118-
119-
type Shared = {
120-
// The version of the shared dependency
121-
version: string;
122-
// Which modules are currently consuming this dependency
123-
useIn: Array<string>;
124-
// From which module does the shared dependency come?
125-
from: string;
126-
// Factory function to get the shared dependency instance. When no other existing dependencies, it will load its own shared dependencies.
127-
lib?: () => Module;
128-
// Sharing strategy, which strategy will be used to decide whether to reuse the dependency
129-
shareConfig: SharedConfig;
130-
// The scope where the shared dependency is located, the default value is default
131-
scope: Array<string>;
132-
// Function to retrieve the shared dependency instance.
133-
get: SharedGetter;
134-
// List of dependencies that this shared module depends on
135-
deps: Array<string>;
136-
// Indicates whether the shared dependency has been loaded
137-
loaded?: boolean;
138-
// Represents the loading state of the shared dependency
139-
loading?: null | Promise<any>;
140-
// Determines if the shared dependency should be loaded eagerly
141-
eager?: boolean;
142113
};
143114
```
144115

@@ -176,6 +147,38 @@ loadRemote('app2/util').then((m) => m.add(1, 2, 3));
176147
- Obtains the `share` dependency. When a "shared" dependency matching the current consumer exists in the global environment, the existing and eligible dependency will be reused first. Otherwise, it loads its own dependency and stores it in the global cache.
177148
- This `API` is usually not called directly by users but is used by the build plugin to convert its own dependencies.
178149

150+
```typescript
151+
type ShareInfos = {
152+
// The name of the dependency, basic information about the dependency, and sharing strategy
153+
[pkgName: string]: Shared[];
154+
};
155+
156+
type Shared = {
157+
// The version of the shared dependency
158+
version: string;
159+
// Which modules are currently consuming this dependency
160+
useIn: Array<string>;
161+
// From which module does the shared dependency come?
162+
from: string;
163+
// Factory function to get the shared dependency instance. When no other existing dependencies, it will load its own shared dependencies.
164+
lib?: () => Module;
165+
// Sharing strategy, which strategy will be used to decide whether to reuse the dependency
166+
shareConfig: SharedConfig;
167+
// The scope where the shared dependency is located, the default value is default
168+
scope: Array<string>;
169+
// Function to retrieve the shared dependency instance.
170+
get: SharedGetter;
171+
// List of dependencies that this shared module depends on
172+
deps: Array<string>;
173+
// Indicates whether the shared dependency has been loaded
174+
loaded?: boolean;
175+
// Represents the loading state of the shared dependency
176+
loading?: null | Promise<any>;
177+
// Determines if the shared dependency should be loaded eagerly
178+
eager?: boolean;
179+
};
180+
```
181+
179182
- Example
180183

181184
```javascript

0 commit comments

Comments
 (0)