@module-federation/native-federation-typescript 0.1.0 → 0.1.2

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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -34
  3. package/dist/CHANGELOG.md +336 -0
  4. package/dist/DTSManagerOptions-3369791f.d.ts +9 -0
  5. package/dist/HostOptions-cf22e0ab.d.ts +23 -0
  6. package/dist/README.md +214 -0
  7. package/dist/chunk-2NC7LVYZ.js +864 -0
  8. package/dist/chunk-CF5CH54A.mjs +864 -0
  9. package/dist/chunk-JLWFNRJL.js +179 -0
  10. package/dist/chunk-QYHGZU7D.mjs +244 -0
  11. package/dist/chunk-VHQW5BQS.js +244 -0
  12. package/dist/chunk-VKKLMSMI.mjs +179 -0
  13. package/dist/esbuild.d.mts +9 -0
  14. package/dist/esbuild.d.ts +6 -3
  15. package/dist/esbuild.js +14 -1
  16. package/dist/esbuild.mjs +14 -1
  17. package/dist/helpers.d.mts +160 -0
  18. package/dist/helpers.d.ts +160 -0
  19. package/dist/helpers.js +40 -0
  20. package/dist/helpers.mjs +40 -0
  21. package/dist/index.d.mts +16 -0
  22. package/dist/index.d.ts +13 -4
  23. package/dist/index.js +10 -1
  24. package/dist/index.mjs +10 -1
  25. package/dist/lib/forkGenerateDts.d.mts +9 -0
  26. package/dist/lib/forkGenerateDts.d.ts +9 -0
  27. package/dist/lib/forkGenerateDts.js +18 -0
  28. package/dist/lib/forkGenerateDts.mjs +18 -0
  29. package/dist/package.json +103 -0
  30. package/dist/rolldown.d.mts +9 -0
  31. package/dist/rolldown.d.ts +9 -0
  32. package/dist/rolldown.js +14 -0
  33. package/dist/rolldown.mjs +14 -0
  34. package/dist/rollup.d.mts +9 -0
  35. package/dist/rollup.d.ts +6 -3
  36. package/dist/rollup.js +14 -1
  37. package/dist/rollup.mjs +14 -1
  38. package/dist/rspack.d.mts +9 -0
  39. package/dist/rspack.d.ts +6 -3
  40. package/dist/rspack.js +14 -1
  41. package/dist/rspack.mjs +14 -1
  42. package/dist/vite.d.mts +9 -0
  43. package/dist/vite.d.ts +6 -3
  44. package/dist/vite.js +14 -1
  45. package/dist/vite.mjs +14 -1
  46. package/dist/webpack.d.mts +9 -0
  47. package/dist/webpack.d.ts +6 -3
  48. package/dist/webpack.js +14 -1
  49. package/dist/webpack.mjs +14 -1
  50. package/package.json +50 -5
  51. package/CHANGELOG.md +0 -28
  52. package/dist/RemoteOptions-ce85caac.d.ts +0 -17
  53. package/dist/chunk-HJB2AKNY.mjs +0 -682
  54. package/dist/chunk-WNKHVVXS.js +0 -682
package/dist/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # native-federation-typescript
2
+
3
+ Bundler agnostic plugins to share federated types.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i -D @module-federation/native-federation-typescript
9
+ ```
10
+
11
+ This module provides two plugins:
12
+
13
+ ### NativeFederationTypeScriptRemote
14
+
15
+ This plugin is used to build the federated types.
16
+
17
+ #### Configuration
18
+
19
+ ```typescript
20
+ {
21
+ moduleFederationConfig: any; // the configuration same configuration provided to the module federation plugin, it is MANDATORY
22
+ tsConfigPath?: string; // path where the tsconfig file is located, default is ''./tsconfig.json'
23
+ typesFolder?: string; // folder where all the files will be stored, default is '@mf-types',
24
+ compiledTypesFolder?: string; // folder where the federated modules types will be stored, default is 'compiled-types'
25
+ deleteTypesFolder?: boolean; // indicate if the types folder will be deleted when the job completes, default is 'true'
26
+ additionalFilesToCompile?: string[] // The path of each additional file which should be emitted
27
+ compilerInstance?: 'tsc' | 'vue-tsc' // The compiler to use to emit files, default is 'tsc'
28
+ }
29
+ ```
30
+
31
+ #### Additional configuration
32
+
33
+ Note that, for Webpack, the plugin automatically inject the `devServer.static.directory` configuration.
34
+ For the other bundlers, you should configure it by yourself.
35
+
36
+ ### NativeFederationTypeScriptHost
37
+
38
+ This plugin is used to download the federated types.
39
+
40
+ ### Configuration
41
+
42
+ ```typescript
43
+ {
44
+ moduleFederationConfig: any; // the configuration same configuration provided to the module federation plugin, it is MANDATORY
45
+ typesFolder?: string; // folder where all the files will be stored, default is '@mf-types',
46
+ deleteTypesFolder?: boolean; // indicate if the types folder will be deleted before the job starts, default is 'true'
47
+ maxRetries?: number; // The number of times the plugin will try to download the types before failing, default is 3
48
+ }
49
+ ```
50
+
51
+ ## Bundler configuration
52
+
53
+ <details>
54
+ <summary>Vite</summary><br>
55
+
56
+ ```ts
57
+ // vite.config.ts
58
+ import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/vite';
59
+
60
+ export default defineConfig({
61
+ plugins: [
62
+ NativeFederationTypeScriptRemote({
63
+ /* options */
64
+ }),
65
+ NativeFederationTypeScriptHost({
66
+ /* options */
67
+ }),
68
+ ],
69
+ /* ... */
70
+ server: {
71
+ // This is needed to emulate the devServer.static.directory of WebPack and correctly serve the zip file
72
+ /* ... */
73
+ proxy: {
74
+ '/@mf-types.zip': {
75
+ target: 'http://localhost:3000',
76
+ changeOrigin: true,
77
+ rewrite: () => `/@fs/${process.cwd()}/dist/@mf-types.zip`,
78
+ },
79
+ },
80
+ fs: {
81
+ /* ... */
82
+ allow: ['./dist'],
83
+ /* ... */
84
+ },
85
+ },
86
+ });
87
+ ```
88
+
89
+ <br>
90
+ </details>
91
+ <details>
92
+ <summary>Rollup</summary><br>
93
+
94
+ ```ts
95
+ // rollup.config.js
96
+ import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/rollup';
97
+
98
+ export default {
99
+ plugins: [
100
+ NativeFederationTypeScriptRemote({
101
+ /* options */
102
+ }),
103
+ NativeFederationTypeScriptHost({
104
+ /* options */
105
+ }),
106
+ ],
107
+ };
108
+ ```
109
+
110
+ <br>
111
+ </details>
112
+ <details>
113
+ <summary>Webpack</summary><br>
114
+
115
+ ```ts
116
+ // webpack.config.js
117
+ const { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/webpack');
118
+ module.exports = {
119
+ /* ... */
120
+ plugins: [
121
+ NativeFederationTypeScriptRemote({
122
+ /* options */
123
+ }),
124
+ NativeFederationTypeScriptHost({
125
+ /* options */
126
+ }),
127
+ ],
128
+ };
129
+ ```
130
+
131
+ <br>
132
+ </details>
133
+ <details>
134
+ <summary>esbuild</summary><br>
135
+
136
+ ```ts
137
+ // esbuild.config.js
138
+ import { build } from 'esbuild';
139
+ import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/esbuild';
140
+
141
+ build({
142
+ plugins: [
143
+ NativeFederationTypeScriptRemote({
144
+ /* options */
145
+ }),
146
+ NativeFederationTypeScriptHost({
147
+ /* options */
148
+ }),
149
+ ],
150
+ });
151
+ ```
152
+
153
+ <br>
154
+ </details>
155
+ <details>
156
+ <summary>Rspack</summary><br>
157
+
158
+ ```ts
159
+ // rspack.config.js
160
+ const { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/rspack');
161
+ module.exports = {
162
+ /* ... */
163
+ plugins: [
164
+ NativeFederationTypeScriptRemote({
165
+ /* options */
166
+ }),
167
+ NativeFederationTypeScriptHost({
168
+ /* options */
169
+ }),
170
+ ],
171
+ };
172
+ ```
173
+
174
+ <br>
175
+ </details>
176
+
177
+ <details>
178
+ <summary>Rolldown</summary><br>
179
+
180
+ ```ts
181
+ // rolldown.config.js
182
+ import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/rolldown';
183
+
184
+ export default {
185
+ plugins: [
186
+ NativeFederationTypeScriptRemote({
187
+ /* options */
188
+ }),
189
+ NativeFederationTypeScriptHost({
190
+ /* options */
191
+ }),
192
+ ],
193
+ };
194
+ ```
195
+
196
+ <br>
197
+ </details>
198
+
199
+ ## TypeScript configuration
200
+
201
+ To have the type definitions automatically found for imports, add paths to the `compilerOptions` in the `tsconfig.json`:
202
+
203
+ ```json
204
+ {
205
+ "paths": {
206
+ "*": ["./@mf-types/*"]
207
+ }
208
+ }
209
+ ```
210
+
211
+ ## Examples
212
+
213
+ To use it in a `host` module, refer to [this example](https://github.com/module-federation/module-federation-examples/tree/master/native-federation-tests-typescript-plugins/host).
214
+ To use it in a `remote` module, refer to [this example](https://github.com/module-federation/module-federation-examples/tree/master/native-federation-tests-typescript-plugins/remote).