webpack-federation-types-plugin 1.3.1 → 1.4.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.
@@ -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: {
@@ -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)
@@ -157,11 +162,16 @@ class FederationTypesPlugin {
157
162
  .then((response) => response?.data)
158
163
  .then((modulesNames) => {
159
164
  if (!modulesNames) return
165
+ // Ensure modulesNames is an array
166
+ if (!Array.isArray(modulesNames)) {
167
+ logger.warn(`Expected array but got ${typeof modulesNames} for remote ${remoteName}`)
168
+ return
169
+ }
160
170
  // for each remote module get his types
161
171
  modulesNames.forEach((moduleName) => {
162
172
  const moduleDeclarationFileUrl = federationTypesUrl + moduleName
163
173
  axios
164
- .get(moduleDeclarationFileUrl)
174
+ .get(moduleDeclarationFileUrl, {headers})
165
175
  .catch((error) => {
166
176
  logger.warn(`Failed to get ${moduleDeclarationFileUrl} ${error.message}`)
167
177
  })
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Daniel Amenou
3
+ Copyright (c) 2026 Daniel Amenou
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # webpack-federation-types-plugin
2
2
 
3
+ [![License](https://img.shields.io/npm/l/webpack-federation-types-plugin.svg)](https://github.com/DanielAmenou/webpack-federation-types-plugin/blob/main/LICENSE) [![npm downloads](https://img.shields.io/npm/dt/webpack-federation-types-plugin.svg)](https://www.npmjs.com/package/webpack-federation-types-plugin) [![npm version](https://img.shields.io/npm/v/webpack-federation-types-plugin.svg)](https://www.npmjs.com/package/webpack-federation-types-plugin)
4
+
3
5
  This plugin generates TypeScript type declaration files for the modules exposed by a remote application. It enables the automatic creation, sharing, and fetching of type definitions for your modules across different applications in a Webpack Module Federation setup.
4
6
 
5
7
  The plugin compiles the exposed modules into TypeScript declaration files and shares them as public assets. On the consumer side, it automatically fetches these remote type declaration files and places them in the standard node_modules/@types directory. This ensures that the consuming application can seamlessly access the type definitions without any additional setup, making the integration of remote types effortless and transparent.
@@ -31,32 +33,37 @@ module.exports = {
31
33
 
32
34
  The plugin takes an options object with the following properties:
33
35
 
34
- ##### exposeTypes
36
+ ### exposeTypes
35
37
 
36
38
  Type: boolean
37
39
  Default: true
38
40
  Description: create and share the declaration files
39
41
 
40
- ##### importTypes
42
+ ### importTypes
41
43
 
42
44
  Type: boolean
43
45
  Default: true
44
46
  Description: fetch the remotes declaration files and add them to the @types directory
45
47
 
46
- ##### excludeRemotes
48
+ ### excludeRemotes
47
49
 
48
50
  Type: string[]
49
51
  Default: undefined
50
52
  Description: remotes to ignore
51
53
 
52
- ##### getTypesInterval
54
+ ### getTypesInterval
53
55
 
54
56
  Type: string
55
57
  Default: undefined
56
58
  Description: the interval between types requests
57
59
  Example: "5 minutes", "30 seconds"
58
60
 
59
- ##### federationConfig
61
+ ### federationConfig
60
62
 
61
63
  Type: object
62
64
  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.
65
+
66
+ ### headers
67
+
68
+ Type: object
69
+ 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.3.1",
4
+ "version": "1.4.1",
5
5
  "main": "FederationTypesPlugin.js",
6
6
  "types": "types.d.ts",
7
7
  "scripts": {
@@ -24,11 +24,11 @@
24
24
  "author": "Daniel Amenou <amenou.daniel@gmail.com>",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "axios": "^1.2.2",
28
- "fs-extra": "^11.1.0",
27
+ "axios": "^1.13.2",
28
+ "fs-extra": "^11.3.3",
29
29
  "ms": "^2.1.3",
30
- "schema-utils": "^4.0.0",
31
- "typescript": "^4.9.4",
30
+ "schema-utils": "^4.3.3",
31
+ "typescript": "^5.9.3",
32
32
  "webpack-merge": "^6.0.1"
33
33
  }
34
34
  }
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