@sbee/vite-federation 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,222 @@
1
+ //#region src/utils/semver/constants.ts
2
+ var buildIdentifier = "[0-9A-Za-z-]+";
3
+ var build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
4
+ var numericIdentifier = "0|[1-9]\\d*";
5
+ var numericIdentifierLoose = "[0-9]+";
6
+ var nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
7
+ var preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
8
+ var preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
9
+ var preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
10
+ var preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
11
+ var xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
12
+ var xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
13
+ var hyphenRange = new RegExp(`^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`);
14
+ var loosePlain = `[v=\\s]*${`(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`}${preReleaseLoose}?${build}?`;
15
+ var gtlt = "((?:<|>)?=?)";
16
+ var comparatorTrim = new RegExp(`(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`);
17
+ var loneTilde = "(?:~>?)";
18
+ var tildeTrim = new RegExp(`(\\s*)${loneTilde}\\s+`);
19
+ var loneCaret = "(?:\\^)";
20
+ var caretTrim = new RegExp(`(\\s*)${loneCaret}\\s+`);
21
+ var star = /* @__PURE__ */ new RegExp("(<|>)?=?\\s*\\*");
22
+ var caret = new RegExp(`^${loneCaret}${xRangePlain}$`);
23
+ var fullPlain = `v?${`(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`}${preRelease}?${build}?`;
24
+ var tilde = new RegExp(`^${loneTilde}${xRangePlain}$`);
25
+ var xRange = new RegExp(`^${gtlt}\\s*${xRangePlain}$`);
26
+ var comparator = new RegExp(`^${gtlt}\\s*(${fullPlain})$|^$`);
27
+ var gte0 = /* @__PURE__ */ new RegExp("^\\s*>=\\s*0.0.0\\s*$");
28
+ //#endregion
29
+ //#region src/utils/semver/utils.ts
30
+ function isXVersion(version) {
31
+ return !version || version.toLowerCase() === "x" || version === "*";
32
+ }
33
+ function pipe(...fns) {
34
+ return (x) => fns.reduce((v, f) => f(v), x);
35
+ }
36
+ function extractComparator(comparatorString) {
37
+ return comparatorString.match(comparator);
38
+ }
39
+ function combineVersion(major, minor, patch, preRelease) {
40
+ const mainVersion = `${major}.${minor}.${patch}`;
41
+ if (preRelease) return `${mainVersion}-${preRelease}`;
42
+ return mainVersion;
43
+ }
44
+ //#endregion
45
+ //#region src/utils/semver/parser.ts
46
+ function parseHyphen(range) {
47
+ return range.replace(hyphenRange, (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease) => {
48
+ if (isXVersion(fromMajor)) from = "";
49
+ else if (isXVersion(fromMinor)) from = `>=${fromMajor}.0.0`;
50
+ else if (isXVersion(fromPatch)) from = `>=${fromMajor}.${fromMinor}.0`;
51
+ else from = `>=${from}`;
52
+ if (isXVersion(toMajor)) to = "";
53
+ else if (isXVersion(toMinor)) to = `<${+toMajor + 1}.0.0-0`;
54
+ else if (isXVersion(toPatch)) to = `<${toMajor}.${+toMinor + 1}.0-0`;
55
+ else if (toPreRelease) to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
56
+ else to = `<=${to}`;
57
+ return `${from} ${to}`.trim();
58
+ });
59
+ }
60
+ function parseComparatorTrim(range) {
61
+ return range.replace(comparatorTrim, "$1$2$3");
62
+ }
63
+ function parseTildeTrim(range) {
64
+ return range.replace(tildeTrim, "$1~");
65
+ }
66
+ function parseCaretTrim(range) {
67
+ return range.replace(caretTrim, "$1^");
68
+ }
69
+ function parseCarets(range) {
70
+ return range.trim().split(/\s+/).map((rangeVersion) => {
71
+ return rangeVersion.replace(caret, (_, major, minor, patch, preRelease) => {
72
+ if (isXVersion(major)) return "";
73
+ else if (isXVersion(minor)) return `>=${major}.0.0 <${+major + 1}.0.0-0`;
74
+ else if (isXVersion(patch)) if (major === "0") return `>=${major}.${minor}.0 <${major}.${+minor + 1}.0-0`;
75
+ else return `>=${major}.${minor}.0 <${+major + 1}.0.0-0`;
76
+ else if (preRelease) if (major === "0") if (minor === "0") return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${minor}.${+patch + 1}-0`;
77
+ else return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${+minor + 1}.0-0`;
78
+ else return `>=${major}.${minor}.${patch}-${preRelease} <${+major + 1}.0.0-0`;
79
+ else {
80
+ if (major === "0") if (minor === "0") return `>=${major}.${minor}.${patch} <${major}.${minor}.${+patch + 1}-0`;
81
+ else return `>=${major}.${minor}.${patch} <${major}.${+minor + 1}.0-0`;
82
+ return `>=${major}.${minor}.${patch} <${+major + 1}.0.0-0`;
83
+ }
84
+ });
85
+ }).join(" ");
86
+ }
87
+ function parseTildes(range) {
88
+ return range.trim().split(/\s+/).map((rangeVersion) => {
89
+ return rangeVersion.replace(tilde, (_, major, minor, patch, preRelease) => {
90
+ if (isXVersion(major)) return "";
91
+ else if (isXVersion(minor)) return `>=${major}.0.0 <${+major + 1}.0.0-0`;
92
+ else if (isXVersion(patch)) return `>=${major}.${minor}.0 <${major}.${+minor + 1}.0-0`;
93
+ else if (preRelease) return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${+minor + 1}.0-0`;
94
+ return `>=${major}.${minor}.${patch} <${major}.${+minor + 1}.0-0`;
95
+ });
96
+ }).join(" ");
97
+ }
98
+ function parseXRanges(range) {
99
+ return range.split(/\s+/).map((rangeVersion) => {
100
+ return rangeVersion.trim().replace(xRange, (ret, gtlt, major, minor, patch, preRelease) => {
101
+ const isXMajor = isXVersion(major);
102
+ const isXMinor = isXMajor || isXVersion(minor);
103
+ const isXPatch = isXMinor || isXVersion(patch);
104
+ if (gtlt === "=" && isXPatch) gtlt = "";
105
+ preRelease = "";
106
+ if (isXMajor) if (gtlt === ">" || gtlt === "<") return "<0.0.0-0";
107
+ else return "*";
108
+ else if (gtlt && isXPatch) {
109
+ if (isXMinor) minor = 0;
110
+ patch = 0;
111
+ if (gtlt === ">") {
112
+ gtlt = ">=";
113
+ if (isXMinor) {
114
+ major = +major + 1;
115
+ minor = 0;
116
+ patch = 0;
117
+ } else {
118
+ minor = +minor + 1;
119
+ patch = 0;
120
+ }
121
+ } else if (gtlt === "<=") {
122
+ gtlt = "<";
123
+ if (isXMinor) major = +major + 1;
124
+ else minor = +minor + 1;
125
+ }
126
+ if (gtlt === "<") preRelease = "-0";
127
+ return `${gtlt + major}.${minor}.${patch}${preRelease}`;
128
+ } else if (isXMinor) return `>=${major}.0.0${preRelease} <${+major + 1}.0.0-0`;
129
+ else if (isXPatch) return `>=${major}.${minor}.0${preRelease} <${major}.${+minor + 1}.0-0`;
130
+ return ret;
131
+ });
132
+ }).join(" ");
133
+ }
134
+ function parseStar(range) {
135
+ return range.trim().replace(star, "");
136
+ }
137
+ function parseGTE0(comparatorString) {
138
+ return comparatorString.trim().replace(gte0, "");
139
+ }
140
+ //#endregion
141
+ //#region src/utils/semver/compare.ts
142
+ function compareAtom(rangeAtom, versionAtom) {
143
+ rangeAtom = +rangeAtom || rangeAtom;
144
+ versionAtom = +versionAtom || versionAtom;
145
+ if (rangeAtom > versionAtom) return 1;
146
+ if (rangeAtom === versionAtom) return 0;
147
+ return -1;
148
+ }
149
+ function comparePreRelease(rangeAtom, versionAtom) {
150
+ const { preRelease: rangePreRelease } = rangeAtom;
151
+ const { preRelease: versionPreRelease } = versionAtom;
152
+ if (rangePreRelease === void 0 && !!versionPreRelease) return 1;
153
+ if (!!rangePreRelease && versionPreRelease === void 0) return -1;
154
+ if (rangePreRelease === void 0 && versionPreRelease === void 0) return 0;
155
+ for (let i = 0, n = rangePreRelease.length; i <= n; i++) {
156
+ const rangeElement = rangePreRelease[i];
157
+ const versionElement = versionPreRelease[i];
158
+ if (rangeElement === versionElement) continue;
159
+ if (rangeElement === void 0 && versionElement === void 0) return 0;
160
+ if (!rangeElement) return 1;
161
+ if (!versionElement) return -1;
162
+ return compareAtom(rangeElement, versionElement);
163
+ }
164
+ return 0;
165
+ }
166
+ function compareVersion(rangeAtom, versionAtom) {
167
+ return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
168
+ }
169
+ function eq(rangeAtom, versionAtom) {
170
+ return rangeAtom.version === versionAtom.version;
171
+ }
172
+ function compare(rangeAtom, versionAtom) {
173
+ switch (rangeAtom.operator) {
174
+ case "":
175
+ case "=": return eq(rangeAtom, versionAtom);
176
+ case ">": return compareVersion(rangeAtom, versionAtom) < 0;
177
+ case ">=": return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
178
+ case "<": return compareVersion(rangeAtom, versionAtom) > 0;
179
+ case "<=": return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
180
+ case void 0: return true;
181
+ default: return false;
182
+ }
183
+ }
184
+ //#endregion
185
+ //#region src/utils/semver/satisfy.ts
186
+ function parseComparatorString(range) {
187
+ return pipe(parseCarets, parseTildes, parseXRanges, parseStar)(range);
188
+ }
189
+ function parseRange(range) {
190
+ return pipe(parseHyphen, parseComparatorTrim, parseTildeTrim, parseCaretTrim)(range.trim()).split(/\s+/).join(" ");
191
+ }
192
+ function satisfy(version, range) {
193
+ if (!version) return false;
194
+ const comparators = parseRange(range).split(" ").map((rangeVersion) => parseComparatorString(rangeVersion)).join(" ").split(/\s+/).map((comparator) => parseGTE0(comparator));
195
+ const extractedVersion = extractComparator(version);
196
+ if (!extractedVersion) return false;
197
+ const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
198
+ const versionAtom = {
199
+ operator: versionOperator,
200
+ version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
201
+ major: versionMajor,
202
+ minor: versionMinor,
203
+ patch: versionPatch,
204
+ preRelease: versionPreRelease?.split(".")
205
+ };
206
+ for (const comparator of comparators) {
207
+ const extractedComparator = extractComparator(comparator);
208
+ if (!extractedComparator) return false;
209
+ const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
210
+ if (!compare({
211
+ operator: rangeOperator,
212
+ version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
213
+ major: rangeMajor,
214
+ minor: rangeMinor,
215
+ patch: rangePatch,
216
+ preRelease: rangePreRelease?.split(".")
217
+ }, versionAtom)) return false;
218
+ }
219
+ return true;
220
+ }
221
+ //#endregion
222
+ export { satisfy };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@sbee/vite-federation",
3
+ "version": "0.0.1",
4
+ "description": "A Vite 8 plugin for Module Federation. Zero runtime dependencies, powered by Rolldown.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./runtime": {
15
+ "types": "./dist/runtime/index.d.ts",
16
+ "import": "./dist/runtime.mjs",
17
+ "require": "./dist/runtime.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "types",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "engines": {
27
+ "node": ">=14.0.0",
28
+ "pnpm": ">=7.0.1"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://git.inet.io.vn/sbee/vite-federation.git"
33
+ },
34
+ "keywords": [
35
+ "vite",
36
+ "plugins"
37
+ ],
38
+ "author": "@sbee",
39
+ "license": "MulanPSL-2.0",
40
+ "bugs": {
41
+ "url": "https://git.inet.io.vn/sbee/vite-federation/issues"
42
+ },
43
+ "homepage": "https://git.inet.io.vn/sbee/vite-federation#readme",
44
+ "scripts": {
45
+ "build": "vite build && tsc -p tsconfig.dts.json",
46
+ "build:types": "tsc -p tsconfig.dts.json",
47
+ "dev": "vite build --watch"
48
+ },
49
+ "dependencies": {},
50
+ "peerDependencies": {
51
+ "vite": ">=7.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^26.1.0",
55
+ "typescript": "^6.0.3",
56
+ "vite": "^8.1.3"
57
+ }
58
+ }
@@ -0,0 +1,334 @@
1
+ /**
2
+ * The following code is adapted from https://git.inet.io.vn/webpack/webpack/types.d.ts
3
+ * MIT License https://git.inet.io.vn/webpack/webpack/LICENSE
4
+ */
5
+ import { RenderedChunk } from 'rolldown'
6
+
7
+ export default function federation(options: VitePluginFederationOptions): Plugin
8
+
9
+ declare interface VitePluginFederationOptions {
10
+ /**
11
+ * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
12
+ */
13
+ exposes?: Exposes
14
+
15
+ /**
16
+ * The filename of the container as relative path inside the `output.path` directory.
17
+ */
18
+ filename?: string
19
+
20
+ /**
21
+ * transform hook need to handle file types
22
+ * default ['.js','.ts','.jsx','.tsx','.mjs','.cjs','.vue','.svelte']
23
+ */
24
+ transformFileTypes?: string[]
25
+
26
+ /**
27
+ * Options for library.
28
+ */
29
+ // library?: LibraryOptions
30
+
31
+ /**
32
+ * The name of the container.
33
+ */
34
+ name?: string
35
+
36
+ /**
37
+ * The external type of the remote containers.
38
+ */
39
+ remoteType?:
40
+ | 'var'
41
+ | 'module'
42
+ | 'assign'
43
+ | 'this'
44
+ | 'window'
45
+ | 'self'
46
+ | 'global'
47
+ | 'commonjs'
48
+ | 'commonjs2'
49
+ | 'commonjs-module'
50
+ | 'amd'
51
+ | 'amd-require'
52
+ | 'umd'
53
+ | 'umd2'
54
+ | 'jsonp'
55
+ | 'system'
56
+ | 'promise'
57
+ | 'import'
58
+ | 'script'
59
+ | 'node-commonjs'
60
+
61
+ /**
62
+ * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
63
+ */
64
+ remotes?: Remotes
65
+
66
+ /**
67
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
68
+ */
69
+ // runtime?: string | false
70
+
71
+ /**
72
+ * Share scope name used for all shared modules (defaults to 'default').
73
+ */
74
+ shareScope?: string
75
+
76
+ /**
77
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
78
+ */
79
+ shared?: Shared
80
+
81
+ /**
82
+ * Current operating mode
83
+ */
84
+ mode?: string
85
+ }
86
+
87
+ type Exposes = (string | ExposesObject)[] | ExposesObject
88
+
89
+ type Remotes = (string | RemotesObject)[] | RemotesObject
90
+
91
+ type Shared = (string | SharedObject)[] | SharedObject
92
+
93
+ type ConfigTypeSet = ExposesConfig | RemotesConfig | SharedConfig
94
+
95
+ declare interface SharedRuntimeInfo {
96
+ id: string
97
+ dependencies: string[]
98
+ fileName: string
99
+ fileDir: string
100
+ filePath: string
101
+ chunk: RenderedChunk
102
+ }
103
+
104
+ /**
105
+ * Modules that should be exposed by this container. Property names are used as public paths.
106
+ */
107
+ declare interface ExposesObject {
108
+ [index: string]: ExposesConfig | string | string[]
109
+ }
110
+
111
+ /**
112
+ * Advanced configuration for modules that should be exposed by this container.
113
+ */
114
+ declare interface ExposesConfig {
115
+ /**
116
+ * Request to a module that should be exposed by this container.
117
+ */
118
+ import: string
119
+
120
+ /**
121
+ * Custom chunk name for the exposed module.
122
+ */
123
+ name?: string
124
+
125
+ /**
126
+ * If false, the link element with styles is put in <head> element. If true, the href argument of all links objects
127
+ * are put under global window object and can be retrieved by the component. It's for using with ShadowDOM, when
128
+ * the component must place the styles inside the ShadowDOM instead of the <head> element.
129
+ */
130
+ dontAppendStylesToHead?: boolean
131
+ }
132
+
133
+ /**
134
+ * Options for library.
135
+ */
136
+ declare interface LibraryOptions {
137
+ /**
138
+ * Add a comment in the UMD wrapper.
139
+ *
140
+ */
141
+ auxiliaryComment?: string | LibraryCustomUmdCommentObject
142
+
143
+ /**
144
+ * Specify which export should be exposed as library.
145
+ *
146
+ */
147
+ export?: string | string[]
148
+
149
+ /**
150
+ * The name of the library (some types allow unnamed libraries too).
151
+ *
152
+ */
153
+ name?: string | string[] | LibraryCustomUmdObject
154
+
155
+ /**
156
+ * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
157
+ *
158
+ */
159
+ type: string
160
+
161
+ /**
162
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
163
+ *
164
+ */
165
+ umdNamedDefine?: boolean
166
+ }
167
+
168
+ /**
169
+ * Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
170
+ */
171
+ declare interface LibraryCustomUmdCommentObject {
172
+ /**
173
+ * Set comment for `amd` section in UMD.
174
+ */
175
+ amd?: string
176
+
177
+ /**
178
+ * Set comment for `commonjs` (exports) section in UMD.
179
+ */
180
+ commonjs?: string
181
+
182
+ /**
183
+ * Set comment for `commonjs2` (module.exports) section in UMD.
184
+ */
185
+ commonjs2?: string
186
+
187
+ /**
188
+ * Set comment for `root` (global variable) section in UMD.
189
+ */
190
+ root?: string
191
+ }
192
+
193
+ /**
194
+ * Description object for all UMD variants of the library name.
195
+ */
196
+ declare interface LibraryCustomUmdObject {
197
+ /**
198
+ * Name of the exposed AMD library in the UMD.
199
+ */
200
+ amd?: string
201
+
202
+ /**
203
+ * Name of the exposed commonjs export in the UMD.
204
+ */
205
+ commonjs?: string
206
+
207
+ /**
208
+ * Name of the property exposed globally by a UMD library.
209
+ */
210
+ root?: string | string[]
211
+ }
212
+
213
+ /**
214
+ * Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
215
+ */
216
+ declare interface RemotesObject {
217
+ [index: string]: string | RemotesConfig | string[] | Promise<any>
218
+ }
219
+
220
+ /**
221
+ * Advanced configuration for container locations from which modules should be resolved and loaded at runtime.
222
+ */
223
+ declare interface RemotesConfig {
224
+ /**
225
+ * Container locations from which modules should be resolved and loaded at runtime.
226
+ */
227
+ external: string[]
228
+
229
+ /**
230
+ * The format of the specified external
231
+ */
232
+ externalType: 'url' | 'promise'
233
+
234
+ /**
235
+ * The name of the share scope shared with this remote.
236
+ */
237
+ shareScope?: string
238
+
239
+ /**
240
+ * the remote format
241
+ */
242
+ format?: 'esm' | 'systemjs' | 'var'
243
+
244
+ /**
245
+ * from
246
+ */
247
+ from?: 'vite' | 'webpack'
248
+ }
249
+
250
+ /**
251
+ * Modules that should be shared in the share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.
252
+ */
253
+ declare interface SharedObject {
254
+ [index: string]: string | SharedConfig
255
+ }
256
+
257
+ /**
258
+ * Advanced configuration for modules that should be shared in the share scope.
259
+ */
260
+ declare interface SharedConfig {
261
+ /**
262
+ * Include the provided and fallback module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
263
+ */
264
+ // eager?: boolean
265
+
266
+ /**
267
+ * Provided module that should be provided to share scope. Also acts as fallback module if no shared module is found in share scope or version isn't valid. Defaults to the property name.
268
+ */
269
+ import?: boolean
270
+
271
+ /**
272
+ * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
273
+ */
274
+ // packageName?: string
275
+
276
+ /**
277
+ * Specify the path to the custom package, the field is not supported in dev mode
278
+ */
279
+ packagePath?: string | undefined
280
+
281
+ /**
282
+ * Version requirement from module in share scope.
283
+ */
284
+ requiredVersion?: string | false
285
+
286
+ /**
287
+ * Module is looked up under this key from the share scope.
288
+ */
289
+ // shareKey?: string
290
+
291
+ /**
292
+ * Share scope name.
293
+ */
294
+ shareScope?: string
295
+
296
+ /**
297
+ * Allow only a single version of the shared module in share scope (disabled by default).
298
+ */
299
+ // singleton?: boolean
300
+
301
+ /**
302
+ * Do not accept shared module if version is not valid (defaults to yes, if local fallback module is available and shared module is not a singleton, otherwise no, has no effect if there is no required version specified).
303
+ */
304
+ // strictVersion?: boolean
305
+
306
+ /**
307
+ * Version of the provided module. Will replace lower matching versions, but not higher.
308
+ */
309
+ version?: string | false
310
+
311
+ /**
312
+ * determine whether to include the shared in the chunk, true is included, false will not generate a shared chunk, only the remote side of the parameter is valid, the host side will definitely generate a shared chunk
313
+ */
314
+ generate?: boolean
315
+
316
+ /**
317
+ * if true, the shared dep will be append in the html head, only valid in prod mode
318
+ */
319
+ modulePreload?: boolean
320
+
321
+ // ── Internal fields (populated by the plugin at build time) ──
322
+ /** Resolved absolute module id (internal) */
323
+ id?: string
324
+ /** Emitted chunk reference id from this.emitFile (internal) */
325
+ emitFile?: string
326
+ /** Whether packagePath was set manually rather than inferred (internal) */
327
+ manuallyPackagePathSetting?: boolean
328
+ /** Marked for removal when the package can't be resolved (internal) */
329
+ removed?: boolean
330
+ /** Module ids that belong to this shared chunk (internal) */
331
+ dependencies?: Set<string>
332
+ /** Root shared entry for mono-repo sub-packages (internal) */
333
+ root?: unknown
334
+ }
@@ -0,0 +1,4 @@
1
+ import { Plugin as VitePlugin } from 'vite'
2
+ export interface PluginHooks extends VitePlugin {
3
+ virtualFile?: Record<string, unknown>
4
+ }
@@ -0,0 +1,22 @@
1
+ import { ViteDevServer as Config } from 'vite'
2
+
3
+ export interface ViteDevServer extends Config {
4
+ _optimizeDepsMetadata?: {
5
+ hash: string
6
+ browserHash: string
7
+ optimized: Map<string, Optimized>
8
+ }
9
+ }
10
+
11
+ declare interface Optimized {
12
+ file: string
13
+ src: string
14
+ needsInterop: boolean
15
+ }
16
+
17
+ export interface Hostname {
18
+ // undefined sets the default behaviour of server.listen
19
+ host: string | undefined
20
+ // resolve to localhost when possible
21
+ name: string
22
+ }