webpack-federation-types-plugin 1.3.0 → 1.4.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/FederationTypesPlugin.js +8 -3
- package/LICENSE +1 -1
- package/README.md +10 -5
- package/package.json +4 -4
- package/types.d.ts +4 -1
package/FederationTypesPlugin.js
CHANGED
|
@@ -32,6 +32,9 @@ const optionsSchema = {
|
|
|
32
32
|
getTypesInterval: {
|
|
33
33
|
type: "string",
|
|
34
34
|
},
|
|
35
|
+
headers: {
|
|
36
|
+
type: "object",
|
|
37
|
+
},
|
|
35
38
|
federationConfig: {
|
|
36
39
|
type: "object",
|
|
37
40
|
properties: {
|
|
@@ -67,7 +70,7 @@ class FederationTypesPlugin {
|
|
|
67
70
|
compiler.options.plugins && compiler.options.plugins.find((plugin) => plugin.constructor.name === "ModuleFederationPlugin")
|
|
68
71
|
if (!federationPlugin) throw new Error("No ModuleFederationPlugin found.")
|
|
69
72
|
|
|
70
|
-
const federationsOptions = merge(federationPlugin._options, this._options.federationConfig)
|
|
73
|
+
const federationsOptions = merge(federationPlugin._options, this._options.federationConfig || {})
|
|
71
74
|
const logger = compiler.getInfrastructureLogger(PLUGIN_NAME)
|
|
72
75
|
|
|
73
76
|
const exposes = Object.fromEntries(
|
|
@@ -147,9 +150,11 @@ class FederationTypesPlugin {
|
|
|
147
150
|
const remoteDeclareDirPath = getRemoteDeclareDirPath(remoteName)
|
|
148
151
|
const federationTypesUrl = remotePublicUrl + MF_TYPES_DIR + "/"
|
|
149
152
|
|
|
153
|
+
const headers = this._options.headers || {}
|
|
154
|
+
|
|
150
155
|
axios
|
|
151
156
|
// get types index from the current remote
|
|
152
|
-
.get(federationTypesUrl + "index.json")
|
|
157
|
+
.get(federationTypesUrl + "index.json", {headers})
|
|
153
158
|
.catch((error) => {
|
|
154
159
|
if (error.response?.status === 404) logger.warn(`WARNING: The remote ${remoteName} has no types`)
|
|
155
160
|
else logger.warn(`Failed to get remote types from ${remotePublicUrl}.`, error.message)
|
|
@@ -161,7 +166,7 @@ class FederationTypesPlugin {
|
|
|
161
166
|
modulesNames.forEach((moduleName) => {
|
|
162
167
|
const moduleDeclarationFileUrl = federationTypesUrl + moduleName
|
|
163
168
|
axios
|
|
164
|
-
.get(moduleDeclarationFileUrl)
|
|
169
|
+
.get(moduleDeclarationFileUrl, {headers})
|
|
165
170
|
.catch((error) => {
|
|
166
171
|
logger.warn(`Failed to get ${moduleDeclarationFileUrl} ${error.message}`)
|
|
167
172
|
})
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -31,32 +31,37 @@ module.exports = {
|
|
|
31
31
|
|
|
32
32
|
The plugin takes an options object with the following properties:
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
### exposeTypes
|
|
35
35
|
|
|
36
36
|
Type: boolean
|
|
37
37
|
Default: true
|
|
38
38
|
Description: create and share the declaration files
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### importTypes
|
|
41
41
|
|
|
42
42
|
Type: boolean
|
|
43
43
|
Default: true
|
|
44
44
|
Description: fetch the remotes declaration files and add them to the @types directory
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
### excludeRemotes
|
|
47
47
|
|
|
48
48
|
Type: string[]
|
|
49
49
|
Default: undefined
|
|
50
50
|
Description: remotes to ignore
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
### getTypesInterval
|
|
53
53
|
|
|
54
54
|
Type: string
|
|
55
55
|
Default: undefined
|
|
56
56
|
Description: the interval between types requests
|
|
57
57
|
Example: "5 minutes", "30 seconds"
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
### federationConfig
|
|
60
60
|
|
|
61
61
|
Type: object
|
|
62
62
|
Description: Allows you to override certain configurations from the ModuleFederationPlugin. You can specify properties such as exposes and remotes to merge or replace the original settings.
|
|
63
|
+
|
|
64
|
+
### headers
|
|
65
|
+
|
|
66
|
+
Type: object
|
|
67
|
+
Description: Allows you to add headers to the fetch request.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-federation-types-plugin",
|
|
3
3
|
"description": "This plugin adds type definitions for remote modules",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"main": "FederationTypesPlugin.js",
|
|
6
6
|
"types": "types.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"author": "Daniel Amenou <amenou.daniel@gmail.com>",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^1.
|
|
28
|
-
"fs-extra": "^11.
|
|
27
|
+
"axios": "^1.7.9",
|
|
28
|
+
"fs-extra": "^11.2.0",
|
|
29
29
|
"ms": "^2.1.3",
|
|
30
|
-
"schema-utils": "^4.
|
|
30
|
+
"schema-utils": "^4.3.0",
|
|
31
31
|
"typescript": "^4.9.4",
|
|
32
32
|
"webpack-merge": "^6.0.1"
|
|
33
33
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
declare interface FederationTypesPluginOptions {
|
|
2
2
|
exposeTypes?: boolean
|
|
3
3
|
importTypes?: boolean
|
|
4
|
+
headers?: object
|
|
4
5
|
excludeRemotes?: string[]
|
|
6
|
+
federationConfig?: object
|
|
7
|
+
getTypesInterval?: string
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
declare class FederationTypesPlugin {
|
|
@@ -9,4 +12,4 @@ declare class FederationTypesPlugin {
|
|
|
9
12
|
apply(compiler: any): void
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export default FederationTypesPlugin
|
|
15
|
+
export default FederationTypesPlugin
|