webpack-federation-types-plugin 1.2.5 → 1.3.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 +207 -196
- package/LICENSE +21 -21
- package/README.md +62 -58
- package/package.json +3 -2
- package/types.d.ts +11 -11
package/FederationTypesPlugin.js
CHANGED
|
@@ -1,196 +1,207 @@
|
|
|
1
|
-
const validate = require("schema-utils").validate
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
1
|
+
const validate = require("schema-utils").validate
|
|
2
|
+
const {merge} = require("webpack-merge")
|
|
3
|
+
const ts = require("typescript")
|
|
4
|
+
const axios = require("axios")
|
|
5
|
+
const fs = require("fs-extra")
|
|
6
|
+
const path = require("path")
|
|
7
|
+
const ms = require("ms")
|
|
8
|
+
|
|
9
|
+
let isFirstCompilation = true
|
|
10
|
+
const PLUGIN_NAME = "FederationTypesPlugin"
|
|
11
|
+
const MF_TYPES_DIR = "federation-types"
|
|
12
|
+
const DECLARATION_FILE_EXT = ".d.ts"
|
|
13
|
+
|
|
14
|
+
const tscOptions = {
|
|
15
|
+
allowJs: true,
|
|
16
|
+
declaration: true,
|
|
17
|
+
emitDeclarationOnly: true,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const optionsSchema = {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
excludeRemotes: {
|
|
24
|
+
type: "array",
|
|
25
|
+
},
|
|
26
|
+
exposeTypes: {
|
|
27
|
+
type: "boolean",
|
|
28
|
+
},
|
|
29
|
+
importTypes: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
},
|
|
32
|
+
getTypesInterval: {
|
|
33
|
+
type: "string",
|
|
34
|
+
},
|
|
35
|
+
federationConfig: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
exposes: {type: "object"},
|
|
39
|
+
remotes: {type: "object"},
|
|
40
|
+
},
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const getAssetData = (content) => {
|
|
47
|
+
const fileBuffer = Buffer.from(content, "utf-8")
|
|
48
|
+
const fileData = {
|
|
49
|
+
source: () => fileBuffer,
|
|
50
|
+
size: () => fileBuffer.length,
|
|
51
|
+
}
|
|
52
|
+
return fileData
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class FederationTypesPlugin {
|
|
56
|
+
constructor(options = {}) {
|
|
57
|
+
validate(optionsSchema, options)
|
|
58
|
+
this._options = options
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {import("webpack").Compiler} compiler
|
|
63
|
+
*/
|
|
64
|
+
apply(compiler) {
|
|
65
|
+
let getTypesInterval
|
|
66
|
+
const federationPlugin =
|
|
67
|
+
compiler.options.plugins && compiler.options.plugins.find((plugin) => plugin.constructor.name === "ModuleFederationPlugin")
|
|
68
|
+
if (!federationPlugin) throw new Error("No ModuleFederationPlugin found.")
|
|
69
|
+
|
|
70
|
+
const federationsOptions = merge(federationPlugin._options, this._options.federationConfig)
|
|
71
|
+
const logger = compiler.getInfrastructureLogger(PLUGIN_NAME)
|
|
72
|
+
|
|
73
|
+
const exposes = Object.fromEntries(
|
|
74
|
+
Object.entries(federationsOptions.exposes || {}).map(([moduleName, currentPath]) => {
|
|
75
|
+
let isIndexFile = false
|
|
76
|
+
const absPath = path.resolve(process.cwd(), currentPath)
|
|
77
|
+
const hasExtension = !!path.extname(currentPath)
|
|
78
|
+
const extension = hasExtension ? "" : fs.existsSync(absPath + ".jsx") ? ".jsx" : fs.existsSync(absPath + ".js") ? ".js" : ""
|
|
79
|
+
if (!hasExtension && extension === "") {
|
|
80
|
+
if (fs.existsSync(path.resolve(absPath, "index.js"))) {
|
|
81
|
+
isIndexFile = true
|
|
82
|
+
} else logger.error(`Couldn't find ${currentPath}`)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return [moduleName.replace("./", ""), currentPath + (isIndexFile ? "/index.js" : "") + extension]
|
|
86
|
+
}),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const modulesPathsMap = Object.fromEntries(
|
|
90
|
+
Object.entries(exposes).map(([name, currentPath]) => {
|
|
91
|
+
return [name, path.join(process.cwd(), currentPath).replace(/\\/g, "/")]
|
|
92
|
+
}),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
const declarationFileToExposeNameMap = Object.entries(modulesPathsMap).reduce(
|
|
96
|
+
(result, [key, val]) => Object.assign(result, {[val.replace(/\.jsx?$/, DECLARATION_FILE_EXT)]: key}),
|
|
97
|
+
{},
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const modulesPaths = Object.values(modulesPathsMap)
|
|
101
|
+
|
|
102
|
+
const createTypesDefinitions = (compilation) => {
|
|
103
|
+
const host = ts.createCompilerHost(tscOptions)
|
|
104
|
+
|
|
105
|
+
const createdFiles = {}
|
|
106
|
+
host.writeFile = (fileName, fileContent) => {
|
|
107
|
+
const isExposedModules = modulesPaths.some((current) => current.startsWith(fileName.replace(/\.d\.ts/, "")))
|
|
108
|
+
if (isExposedModules) {
|
|
109
|
+
createdFiles[fileName] = fileContent
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const program = ts.createProgram(modulesPaths, tscOptions, host)
|
|
114
|
+
program.emit()
|
|
115
|
+
|
|
116
|
+
// create definitions files
|
|
117
|
+
modulesPaths.forEach((modulePath) => {
|
|
118
|
+
const typeDefFilePath = modulePath.replace(/\.jsx?$/, DECLARATION_FILE_EXT)
|
|
119
|
+
const typeDefFileContent = createdFiles[typeDefFilePath]
|
|
120
|
+
if (typeDefFileContent) {
|
|
121
|
+
compilation.emitAsset(
|
|
122
|
+
path.join(MF_TYPES_DIR, declarationFileToExposeNameMap[typeDefFilePath] + DECLARATION_FILE_EXT),
|
|
123
|
+
getAssetData(typeDefFileContent),
|
|
124
|
+
)
|
|
125
|
+
} else {
|
|
126
|
+
logger.warn(`failed to create ${typeDefFilePath}`)
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// create index.json
|
|
131
|
+
const modulesNames = Object.keys(exposes).map((moduleName) => moduleName + DECLARATION_FILE_EXT)
|
|
132
|
+
compilation.emitAsset(path.join(MF_TYPES_DIR, "index.json"), getAssetData(JSON.stringify(modulesNames)))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const getRemoteDeclareDirPath = (remoteName) => path.resolve(process.cwd(), "node_modules", "@types", remoteName)
|
|
136
|
+
|
|
137
|
+
const getTypesDefinitions = async () => {
|
|
138
|
+
const remotes = federationsOptions.remotes
|
|
139
|
+
if (!remotes) return
|
|
140
|
+
|
|
141
|
+
const excludeRemotes = this._options.excludeRemotes || []
|
|
142
|
+
const wantedRemotes = Object.entries(remotes).filter((remote) => !excludeRemotes.find((c) => c === remote[0]))
|
|
143
|
+
|
|
144
|
+
for (const [remoteName, remoteEntryUri] of wantedRemotes) {
|
|
145
|
+
const {origin, pathname} = new URL(remoteEntryUri.split("@")[1])
|
|
146
|
+
const remotePublicUrl = origin + pathname.slice(0, pathname.lastIndexOf("/") + 1)
|
|
147
|
+
const remoteDeclareDirPath = getRemoteDeclareDirPath(remoteName)
|
|
148
|
+
const federationTypesUrl = remotePublicUrl + MF_TYPES_DIR + "/"
|
|
149
|
+
|
|
150
|
+
axios
|
|
151
|
+
// get types index from the current remote
|
|
152
|
+
.get(federationTypesUrl + "index.json")
|
|
153
|
+
.catch((error) => {
|
|
154
|
+
if (error.response?.status === 404) logger.warn(`WARNING: The remote ${remoteName} has no types`)
|
|
155
|
+
else logger.warn(`Failed to get remote types from ${remotePublicUrl}.`, error.message)
|
|
156
|
+
})
|
|
157
|
+
.then((response) => response?.data)
|
|
158
|
+
.then((modulesNames) => {
|
|
159
|
+
if (!modulesNames) return
|
|
160
|
+
// for each remote module get his types
|
|
161
|
+
modulesNames.forEach((moduleName) => {
|
|
162
|
+
const moduleDeclarationFileUrl = federationTypesUrl + moduleName
|
|
163
|
+
axios
|
|
164
|
+
.get(moduleDeclarationFileUrl)
|
|
165
|
+
.catch((error) => {
|
|
166
|
+
logger.warn(`Failed to get ${moduleDeclarationFileUrl} ${error.message}`)
|
|
167
|
+
})
|
|
168
|
+
.then((declarationFileResponse) => {
|
|
169
|
+
if (!declarationFileResponse) return
|
|
170
|
+
const declarationFileContent = declarationFileResponse.data
|
|
171
|
+
const decFilePath = path.join(remoteDeclareDirPath, moduleName)
|
|
172
|
+
fs.promises
|
|
173
|
+
.mkdir(path.dirname(decFilePath), {recursive: true})
|
|
174
|
+
.catch((error) => logger.error(`Failed to write dir: ${decFilePath}`, error))
|
|
175
|
+
.then(() => fs.writeFile(decFilePath, declarationFileContent, {recursive: true}))
|
|
176
|
+
.catch((error) => logger.error(`Failed to write declaration file: ${decFilePath}`, error))
|
|
177
|
+
})
|
|
178
|
+
.catch((error) => {
|
|
179
|
+
logger.warn(`Failed to get ${moduleDeclarationFileUrl} ${error.message}`)
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
.catch((error) => {
|
|
184
|
+
logger.error("Failed to add declaration file", error.message)
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
190
|
+
const pluginOptions = this._options || {}
|
|
191
|
+
compilation.hooks.beforeCodeGeneration.tap(PLUGIN_NAME, () => {
|
|
192
|
+
if (!isFirstCompilation) return
|
|
193
|
+
isFirstCompilation = false
|
|
194
|
+
if (pluginOptions.exposeTypes !== false) createTypesDefinitions(compilation)
|
|
195
|
+
if (compilation.options.mode === "development" && pluginOptions.importTypes !== false) {
|
|
196
|
+
getTypesDefinitions()
|
|
197
|
+
if (pluginOptions.getTypesInterval) {
|
|
198
|
+
clearInterval(getTypesInterval)
|
|
199
|
+
getTypesInterval = setInterval(() => getTypesDefinitions(compilation), ms(pluginOptions.getTypesInterval))
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
module.exports = FederationTypesPlugin
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Daniel Amenou
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Daniel Amenou
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
# webpack-federation-types-plugin
|
|
2
|
-
|
|
3
|
-
This plugin generates TypeScript type declaration files for the modules
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
# webpack-federation-types-plugin
|
|
2
|
+
|
|
3
|
+
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
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
You can install the plugin by running the following command in your terminal:
|
|
10
|
+
|
|
11
|
+
`npm i --save-dev webpack-federation-types-plugin`
|
|
12
|
+
|
|
13
|
+
`yarn add --dev webpack-federation-types-plugin`
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
After installing the plugin, you can use it in your webpack configuration file as follows:
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const FederationTypesPlugin = require("webpack-federation-types-plugin")
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
// ...
|
|
24
|
+
plugins: [new FederationTypesPlugin({excludeRemotes: ["remoteName"], importTypes: true, exposeTypes: true})],
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- This plugin should be added to the browser config
|
|
29
|
+
|
|
30
|
+
## Plugin Options
|
|
31
|
+
|
|
32
|
+
The plugin takes an options object with the following properties:
|
|
33
|
+
|
|
34
|
+
##### exposeTypes
|
|
35
|
+
|
|
36
|
+
Type: boolean
|
|
37
|
+
Default: true
|
|
38
|
+
Description: create and share the declaration files
|
|
39
|
+
|
|
40
|
+
##### importTypes
|
|
41
|
+
|
|
42
|
+
Type: boolean
|
|
43
|
+
Default: true
|
|
44
|
+
Description: fetch the remotes declaration files and add them to the @types directory
|
|
45
|
+
|
|
46
|
+
##### excludeRemotes
|
|
47
|
+
|
|
48
|
+
Type: string[]
|
|
49
|
+
Default: undefined
|
|
50
|
+
Description: remotes to ignore
|
|
51
|
+
|
|
52
|
+
##### getTypesInterval
|
|
53
|
+
|
|
54
|
+
Type: string
|
|
55
|
+
Default: undefined
|
|
56
|
+
Description: the interval between types requests
|
|
57
|
+
Example: "5 minutes", "30 seconds"
|
|
58
|
+
|
|
59
|
+
##### federationConfig
|
|
60
|
+
|
|
61
|
+
Type: object
|
|
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.
|
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.3.0",
|
|
5
5
|
"main": "FederationTypesPlugin.js",
|
|
6
6
|
"types": "types.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"fs-extra": "^11.1.0",
|
|
29
29
|
"ms": "^2.1.3",
|
|
30
30
|
"schema-utils": "^4.0.0",
|
|
31
|
-
"typescript": "^4.9.4"
|
|
31
|
+
"typescript": "^4.9.4",
|
|
32
|
+
"webpack-merge": "^6.0.1"
|
|
32
33
|
}
|
|
33
34
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
declare interface FederationTypesPluginOptions {
|
|
2
|
-
exposeTypes?: boolean
|
|
3
|
-
importTypes?: boolean
|
|
4
|
-
excludeRemotes?: string[]
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare class FederationTypesPlugin {
|
|
8
|
-
constructor(options?: FederationTypesPluginOptions)
|
|
9
|
-
apply(compiler: any): void
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
declare interface FederationTypesPluginOptions {
|
|
2
|
+
exposeTypes?: boolean
|
|
3
|
+
importTypes?: boolean
|
|
4
|
+
excludeRemotes?: string[]
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare class FederationTypesPlugin {
|
|
8
|
+
constructor(options?: FederationTypesPluginOptions)
|
|
9
|
+
apply(compiler: any): void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
12
|
export default FederationTypesPlugin
|