@module-federation/native-federation-typescript 0.2.5 → 1.0.0-canary.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.
- package/CHANGELOG.md +28 -48
- package/README.md +57 -32
- package/dist/{chunk-5DG6MWZH.js → chunk-P5PXJORB.js} +2 -2
- package/dist/{chunk-2JPDJNBW.mjs → chunk-ZPCKDOMT.mjs} +2 -2
- package/dist/esbuild.js +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/rollup.d.mts +2 -2
- package/dist/rollup.d.ts +2 -2
- package/dist/rollup.js +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,90 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
-
## [0.2.
|
|
6
|
-
|
|
5
|
+
## [0.2.6](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.2.5...native-federation-typescript-0.2.6) (2023-07-01)
|
|
7
6
|
|
|
7
|
+
## [0.2.5](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.2.4...native-federation-typescript-0.2.5) (2023-07-01)
|
|
8
8
|
|
|
9
9
|
## [0.2.4](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.2.3...native-federation-typescript-0.2.4) (2023-07-01)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
11
|
## [0.2.3](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.2.2...native-federation-typescript-0.2.3) (2023-07-01)
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
13
|
## [0.2.2](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.2.1...native-federation-typescript-0.2.2) (2023-06-28)
|
|
18
14
|
|
|
19
|
-
|
|
20
15
|
### Bug Fixes
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
- .at(-1) ([8dd0520](https://github.com/module-federation/nextjs-mf/commit/8dd0520b5464c49e89c63307c5388450e4bebbf8))
|
|
25
18
|
|
|
26
19
|
## [0.2.1](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.2.0...native-federation-typescript-0.2.1) (2023-05-13)
|
|
27
20
|
|
|
28
|
-
|
|
29
21
|
### Bug Fixes
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
- [#857](https://github.com/module-federation/nextjs-mf/issues/857) ([#859](https://github.com/module-federation/nextjs-mf/issues/859)) ([2fb609e](https://github.com/module-federation/nextjs-mf/commit/2fb609efb9a3c8f3e6740e0159510d649c1d229d))
|
|
24
|
+
- downgrade next to v13.3.1 ([0032452](https://github.com/module-federation/nextjs-mf/commit/0032452980c70b211b6c04332326b7973f7c8446))
|
|
25
|
+
- removed lock ([82f578e](https://github.com/module-federation/nextjs-mf/commit/82f578e713734f7f6b06e09b794fab4f66af248a))
|
|
36
26
|
|
|
37
27
|
# [0.2.0](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.1.1...native-federation-typescript-0.2.0) (2023-04-29)
|
|
38
28
|
|
|
39
|
-
|
|
40
29
|
### Bug Fixes
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
- removed any from error logger type ([fb9fcc3](https://github.com/module-federation/nextjs-mf/commit/fb9fcc3a54a13be36335830f076a86557b75bb4a))
|
|
32
|
+
- subpath ([1548501](https://github.com/module-federation/nextjs-mf/commit/1548501bb4679c0c534c02609cb6bc5459f224a4))
|
|
33
|
+
- subpath ([aaad665](https://github.com/module-federation/nextjs-mf/commit/aaad665307d80b49ee19496a5b8b400df243558e))
|
|
46
34
|
|
|
47
35
|
### Features
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
- release to npm with next tag to not ruine latest one ([#763](https://github.com/module-federation/nextjs-mf/issues/763)) ([f2d199b](https://github.com/module-federation/nextjs-mf/commit/f2d199b3b3fbbd428514b1ce1f139efc82f7fff0))
|
|
52
38
|
|
|
53
39
|
## [0.1.1](https://github.com/module-federation/nextjs-mf/compare/native-federation-typescript-0.1.0...native-federation-typescript-0.1.1) (2023-04-12)
|
|
54
40
|
|
|
55
|
-
|
|
56
41
|
### Bug Fixes
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
- native build chunks ([d6c9f8a](https://github.com/module-federation/nextjs-mf/commit/d6c9f8a957ed00a8d92332ccc38ed9780f01d54e))
|
|
60
44
|
|
|
61
45
|
### Reverts
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
- Revert "chore(native-federation-typescript): release version 0.1.1" ([91786df](https://github.com/module-federation/nextjs-mf/commit/91786df726e5c078ed78e745b6b105e11bd2e39b))
|
|
48
|
+
- Revert "chore(native-federation-typescript): release version 0.1.1" ([097f188](https://github.com/module-federation/nextjs-mf/commit/097f188458835457a2713d98bf3eaf291d5ad102))
|
|
67
49
|
|
|
68
50
|
# 0.1.0 (2023-04-05)
|
|
69
51
|
|
|
70
|
-
|
|
71
52
|
### Bug Fixes
|
|
72
53
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
54
|
+
- build ([d0b2f72](https://github.com/module-federation/nextjs-mf/commit/d0b2f72f4fc3647825412be1574311c3152cf167))
|
|
55
|
+
- build step ([a217170](https://github.com/module-federation/nextjs-mf/commit/a21717096cbc09bff20d3aeebfea2f3533afb0d7))
|
|
56
|
+
- compiler instance ([e5c249d](https://github.com/module-federation/nextjs-mf/commit/e5c249d41d68339886268337654ff47b31b06a3a))
|
|
57
|
+
- deps ([a378441](https://github.com/module-federation/nextjs-mf/commit/a37844194a3f189cc5863bbdd4776259bce69fa4))
|
|
58
|
+
- dirtree tests ([5cb49fd](https://github.com/module-federation/nextjs-mf/commit/5cb49fd1c6520311a7d2e7d2b37a93389a500715))
|
|
59
|
+
- eslintrc ([0f69dee](https://github.com/module-federation/nextjs-mf/commit/0f69dee253c2c608b2367d545c7d4a57ad0c2ca5))
|
|
60
|
+
- format ([25fb765](https://github.com/module-federation/nextjs-mf/commit/25fb7659481287a791e9de4fe839e980dbf06968))
|
|
61
|
+
- readme ([eaca0b3](https://github.com/module-federation/nextjs-mf/commit/eaca0b311d3b8d9e73309cb92d9a9488f9fc23c0))
|
|
62
|
+
- readme ([fc0e5dc](https://github.com/module-federation/nextjs-mf/commit/fc0e5dc26e617664224e1c10548b151a44f8dff9))
|
|
63
|
+
- README.md ([9159171](https://github.com/module-federation/nextjs-mf/commit/91591712e9a103fff351f0a168c149470c0d69ad))
|
|
64
|
+
- remove changelog ([724918e](https://github.com/module-federation/nextjs-mf/commit/724918ebf888297689b6ed700bd14ec01fd1ef35))
|
|
65
|
+
- ts build ([9ed3a52](https://github.com/module-federation/nextjs-mf/commit/9ed3a527d0ba903b6cfa6023a7ad5da63781970c))
|
|
86
66
|
|
|
87
67
|
### Features
|
|
88
68
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
- federated tests plugin ([063ab33](https://github.com/module-federation/nextjs-mf/commit/063ab336c4830aff4f5bd3b9894df60b4651a9be))
|
|
70
|
+
- native-federation-typescript plugin ([#692](https://github.com/module-federation/nextjs-mf/issues/692)) ([b41c5aa](https://github.com/module-federation/nextjs-mf/commit/b41c5aacfeda0fada5b426086658235edfd86cdd))
|
|
71
|
+
- test command ([3ade629](https://github.com/module-federation/nextjs-mf/commit/3ade629488f4ea1549314b82b41caef9a046da9f))
|
package/README.md
CHANGED
|
@@ -11,9 +11,11 @@ npm i -D @module-federation/native-federation-typescript
|
|
|
11
11
|
This module provides two plugins:
|
|
12
12
|
|
|
13
13
|
### NativeFederationTypeScriptRemote
|
|
14
|
+
|
|
14
15
|
This plugin is used to build the federated types.
|
|
15
16
|
|
|
16
17
|
#### Configuration
|
|
18
|
+
|
|
17
19
|
```typescript
|
|
18
20
|
{
|
|
19
21
|
moduleFederationConfig: any; // the configuration same configuration provided to the module federation plugin, it is MANDATORY
|
|
@@ -27,10 +29,12 @@ This plugin is used to build the federated types.
|
|
|
27
29
|
```
|
|
28
30
|
|
|
29
31
|
#### Additional configuration
|
|
32
|
+
|
|
30
33
|
Note that, for Webpack, the plugin automatically inject the `devServer.static.directory` configuration.
|
|
31
34
|
For the other bundlers, you should configure it by yourself.
|
|
32
35
|
|
|
33
36
|
### NativeFederationTypeScriptHost
|
|
37
|
+
|
|
34
38
|
This plugin is used to download the federated types.
|
|
35
39
|
|
|
36
40
|
### Configuration
|
|
@@ -50,30 +54,35 @@ This plugin is used to download the federated types.
|
|
|
50
54
|
|
|
51
55
|
```ts
|
|
52
56
|
// vite.config.ts
|
|
53
|
-
import {NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote} from '@module-federation/native-federation-typescript/vite'
|
|
57
|
+
import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/vite';
|
|
54
58
|
|
|
55
59
|
export default defineConfig({
|
|
56
60
|
plugins: [
|
|
57
|
-
NativeFederationTypeScriptRemote({
|
|
58
|
-
|
|
61
|
+
NativeFederationTypeScriptRemote({
|
|
62
|
+
/* options */
|
|
63
|
+
}),
|
|
64
|
+
NativeFederationTypeScriptHost({
|
|
65
|
+
/* options */
|
|
66
|
+
}),
|
|
59
67
|
],
|
|
60
68
|
/* ... */
|
|
61
|
-
server: {
|
|
69
|
+
server: {
|
|
70
|
+
// This is needed to emulate the devServer.static.directory of WebPack and correctly serve the zip file
|
|
62
71
|
/* ... */
|
|
63
72
|
proxy: {
|
|
64
73
|
'/@mf-types.zip': {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
74
|
+
target: 'http://localhost:3000',
|
|
75
|
+
changeOrigin: true,
|
|
76
|
+
rewrite: () => `/@fs/${process.cwd()}/dist/@mf-types.zip`,
|
|
77
|
+
},
|
|
69
78
|
},
|
|
70
79
|
fs: {
|
|
71
80
|
/* ... */
|
|
72
|
-
allow: ['./dist']
|
|
81
|
+
allow: ['./dist'],
|
|
73
82
|
/* ... */
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
})
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
77
86
|
```
|
|
78
87
|
|
|
79
88
|
<br>
|
|
@@ -83,14 +92,18 @@ export default defineConfig({
|
|
|
83
92
|
|
|
84
93
|
```ts
|
|
85
94
|
// rollup.config.js
|
|
86
|
-
import {NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote} from '@module-federation/native-federation-typescript/rollup'
|
|
95
|
+
import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/rollup';
|
|
87
96
|
|
|
88
97
|
export default {
|
|
89
98
|
plugins: [
|
|
90
|
-
NativeFederationTypeScriptRemote({
|
|
91
|
-
|
|
99
|
+
NativeFederationTypeScriptRemote({
|
|
100
|
+
/* options */
|
|
101
|
+
}),
|
|
102
|
+
NativeFederationTypeScriptHost({
|
|
103
|
+
/* options */
|
|
104
|
+
}),
|
|
92
105
|
],
|
|
93
|
-
}
|
|
106
|
+
};
|
|
94
107
|
```
|
|
95
108
|
|
|
96
109
|
<br>
|
|
@@ -100,14 +113,18 @@ export default {
|
|
|
100
113
|
|
|
101
114
|
```ts
|
|
102
115
|
// webpack.config.js
|
|
103
|
-
const {NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote} = require('@module-federation/native-federation-typescript/webpack')
|
|
116
|
+
const { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/webpack');
|
|
104
117
|
module.exports = {
|
|
105
118
|
/* ... */
|
|
106
119
|
plugins: [
|
|
107
|
-
NativeFederationTypeScriptRemote({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
NativeFederationTypeScriptRemote({
|
|
121
|
+
/* options */
|
|
122
|
+
}),
|
|
123
|
+
NativeFederationTypeScriptHost({
|
|
124
|
+
/* options */
|
|
125
|
+
}),
|
|
126
|
+
],
|
|
127
|
+
};
|
|
111
128
|
```
|
|
112
129
|
|
|
113
130
|
<br>
|
|
@@ -117,15 +134,19 @@ module.exports = {
|
|
|
117
134
|
|
|
118
135
|
```ts
|
|
119
136
|
// esbuild.config.js
|
|
120
|
-
import { build } from 'esbuild'
|
|
121
|
-
import {NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote} from '@module-federation/native-federation-typescript/esbuild'
|
|
137
|
+
import { build } from 'esbuild';
|
|
138
|
+
import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/esbuild';
|
|
122
139
|
|
|
123
140
|
build({
|
|
124
141
|
plugins: [
|
|
125
|
-
NativeFederationTypeScriptRemote({
|
|
126
|
-
|
|
142
|
+
NativeFederationTypeScriptRemote({
|
|
143
|
+
/* options */
|
|
144
|
+
}),
|
|
145
|
+
NativeFederationTypeScriptHost({
|
|
146
|
+
/* options */
|
|
147
|
+
}),
|
|
127
148
|
],
|
|
128
|
-
})
|
|
149
|
+
});
|
|
129
150
|
```
|
|
130
151
|
|
|
131
152
|
<br>
|
|
@@ -135,14 +156,18 @@ build({
|
|
|
135
156
|
|
|
136
157
|
```ts
|
|
137
158
|
// rspack.config.js
|
|
138
|
-
const {NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote} = require('@module-federation/native-federation-typescript/rspack')
|
|
159
|
+
const { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/rspack');
|
|
139
160
|
module.exports = {
|
|
140
161
|
/* ... */
|
|
141
162
|
plugins: [
|
|
142
|
-
NativeFederationTypeScriptRemote({
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
NativeFederationTypeScriptRemote({
|
|
164
|
+
/* options */
|
|
165
|
+
}),
|
|
166
|
+
NativeFederationTypeScriptHost({
|
|
167
|
+
/* options */
|
|
168
|
+
}),
|
|
169
|
+
],
|
|
170
|
+
};
|
|
146
171
|
```
|
|
147
172
|
|
|
148
173
|
<br>
|
|
@@ -153,7 +178,7 @@ module.exports = {
|
|
|
153
178
|
To have the type definitions automatically found for imports, add paths to the `compilerOptions` in the `tsconfig.json`:
|
|
154
179
|
|
|
155
180
|
```json
|
|
156
|
-
{
|
|
181
|
+
{
|
|
157
182
|
"paths": {
|
|
158
183
|
"*": ["./@mf-types/*"]
|
|
159
184
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var I=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var _ansicolors = require('ansi-colors'); var _ansicolors2 = _interopRequireDefault(_ansicolors);var _promises = require('fs/promises');var _path = require('path');var _rambda = require('rambda');var _unplugin = require('unplugin');var U={typesFolder:"@mf-types",deleteTypesFolder:!0},L=t=>{let e=t.split("@");return e[e.length-1]},z=(t,e)=>{let o=L(e),r=new URL(o),s=r.pathname.split("/").slice(0,-1).join("/");return r.pathname=`${s}/${t.typesFolder}.zip`,r.href},W=t=>Object.entries(t.moduleFederationConfig.remotes).reduce((e,[o,r])=>(e[o]=z(t,r),e),{}),T=t=>{if(!t.moduleFederationConfig)throw new Error("moduleFederationConfig is required");let e={...U,...t},o=W(e);return{hostOptions:e,mapRemotesToDownload:o}};var _fs = require('fs');var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);var
|
|
2
|
-
export { default } from './${O}';`,f)}}},r},te=t=>I("vue-tsc").createProgram(t),oe=(t,e)=>{switch(t.compilerInstance){case"vue-tsc":return te(e);case"tsc":default:return _typescript2.default.createProgram(e)}},x=(t,e,o)=>{let r=ee(t,e,o),i={rootNames:[...Object.values(t),...o.additionalFilesToCompile],host:r,options:e},p=oe(o,i),{diagnostics:n=[]}=p.emit();n.forEach(Y)};var ie=(t,e)=>_path.join.call(void 0, t.replace(e.typesFolder,""),`${e.typesFolder}.zip`),$=async(t,e)=>{let o=c(t,e),r=new _admzip2.default;return r.addLocalFolder(o),r.writeZipPromise(ie(o,e))},ne=(t,e)=>o=>{throw
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var I=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var _ansicolors = require('ansi-colors'); var _ansicolors2 = _interopRequireDefault(_ansicolors);var _promises = require('fs/promises');var _path = require('path');var _rambda = require('rambda');var _unplugin = require('unplugin');var U={typesFolder:"@mf-types",deleteTypesFolder:!0},L=t=>{let e=t.split("@");return e[e.length-1]},z=(t,e)=>{let o=L(e),r=new URL(o),s=r.pathname.split("/").slice(0,-1).join("/");return r.pathname=`${s}/${t.typesFolder}.zip`,r.href},W=t=>Object.entries(t.moduleFederationConfig.remotes).reduce((e,[o,r])=>(e[o]=z(t,r),e),{}),T=t=>{if(!t.moduleFederationConfig)throw new Error("moduleFederationConfig is required");let e={...U,...t},o=W(e);return{hostOptions:e,mapRemotesToDownload:o}};var _fs = require('fs');var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);var M={tsConfigPath:"./tsconfig.json",typesFolder:"@mf-types",compiledTypesFolder:"compiled-types",deleteTypesFolder:!0,additionalFilesToCompile:[],compilerInstance:"tsc"},B=({tsConfigPath:t,typesFolder:e,compiledTypesFolder:o})=>{let r=_path.resolve.call(void 0, t),s=_typescript2.default.readConfigFile(r,_typescript2.default.sys.readFile),i=_typescript2.default.parseJsonConfigFileContent(s.config,_typescript2.default.sys,_path.dirname.call(void 0, r)),p=_path.join.call(void 0, i.options.outDir||"dist",e,o);return{...i.options,emitDeclarationOnly:!0,noEmit:!1,declaration:!0,outDir:p}},X=["ts","tsx","vue","svelte"],R=t=>{let e=process.cwd();for(let o of X){let r=_path.join.call(void 0, e,`${t}.${o}`);if(_fs.existsSync.call(void 0, r))return r}},J=t=>Object.entries(t.moduleFederationConfig.exposes).reduce((e,[o,r])=>(e[o]=R(r)||R(_path.join.call(void 0, r,"index"))||r,e),{}),v=t=>{if(!t.moduleFederationConfig)throw new Error("moduleFederationConfig is required");let e={...M,...t},o=J(e);return{tsConfig:B(e),mapComponentsToExpose:o,remoteOptions:e}};var _admzip = require('adm-zip'); var _admzip2 = _interopRequireDefault(_admzip);var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);var Q=/^\//,F=".d.ts",Y=t=>{let{line:e}=t.file.getLineAndCharacterOfPosition(t.start);console.error(_ansicolors2.default.red(`TS Error ${t.code}':' ${_typescript2.default.flattenDiagnosticMessageText(t.messageText,_typescript2.default.sys.newLine)}`)),console.error(_ansicolors2.default.red(` at ${t.file.fileName}:${e+1} typescript.sys.newLine`))},c=(t,e)=>_path.normalize.call(void 0, t.outDir.replace(e.compiledTypesFolder,"")),w=(t,e)=>_path.normalize.call(void 0, t.outDir.replace(e.compiledTypesFolder,"").replace(e.typesFolder,"")),ee=(t,e,o)=>{let r=_typescript2.default.createCompilerHost(e),s=r.writeFile,i=Object.fromEntries(Object.entries(t).map(n=>n.reverse())),p=c(e,o);return r.writeFile=(n,D,f,b,u,N)=>{s(n,D,f,b,u,N);for(let j of u||[]){let y=i[j.fileName];if(y){let g=_path.join.call(void 0, p,`${y}${F}`),A=_path.dirname.call(void 0, g),O=_path.relative.call(void 0, A,n).replace(F,"").replace(Q,"");s(g,`export * from './${O}';
|
|
2
|
+
export { default } from './${O}';`,f)}}},r},te=t=>I("vue-tsc").createProgram(t),oe=(t,e)=>{switch(t.compilerInstance){case"vue-tsc":return te(e);case"tsc":default:return _typescript2.default.createProgram(e)}},x=(t,e,o)=>{let r=ee(t,e,o),i={rootNames:[...Object.values(t),...o.additionalFilesToCompile],host:r,options:e},p=oe(o,i),{diagnostics:n=[]}=p.emit();n.forEach(Y)};var ie=(t,e)=>_path.join.call(void 0, t.replace(e.typesFolder,""),`${e.typesFolder}.zip`),$=async(t,e)=>{let o=c(t,e),r=new _admzip2.default;return r.addLocalFolder(o),r.writeZipPromise(ie(o,e))},ne=(t,e)=>o=>{throw o.message=_ansicolors2.default.red(`Network error: Unable to download federated mocks for '${t}' from '${e}' because '${o.message}', skipping...`),o},H=t=>async([e,o])=>{let r=await _axios2.default.get(o,{responseType:"arraybuffer"}).catch(ne(e,o)),s=_path.join.call(void 0, t.typesFolder,e);new (0, _admzip2.default)(Buffer.from(r.data)).extractAllTo(s,!0)};var Ne=_unplugin.createUnplugin.call(void 0, t=>{let{remoteOptions:e,tsConfig:o,mapComponentsToExpose:r}=v(t);return{name:"native-federation-typescript/remote",async writeBundle(){try{x(r,o,e),await $(o,e),e.deleteTypesFolder&&await _promises.rm.call(void 0, c(o,e),{recursive:!0,force:!0}),console.log(_ansicolors2.default.green("Federated types created correctly"))}catch(s){console.error(_ansicolors2.default.red(`Unable to compile federated types, ${s}`))}},webpack:s=>{s.options.devServer=_rambda.mergeDeepRight.call(void 0, s.options.devServer||{},{static:{directory:_path.resolve.call(void 0, w(o,e))}})}}}),je= exports.b =_unplugin.createUnplugin.call(void 0, t=>{let{hostOptions:e,mapRemotesToDownload:o}=T(t);return{name:"native-federation-typescript/host",async writeBundle(){e.deleteTypesFolder&&await _promises.rm.call(void 0, e.typesFolder,{recursive:!0,force:!0}).catch(i=>console.error(_ansicolors2.default.red(`Unable to remove types folder, ${i}`)));let r=H(e),s=Object.entries(o).map(r);await Promise.allSettled(s),console.log(_ansicolors2.default.green("Federated types extraction completed"))}}});exports.a = Ne; exports.b = je;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var I=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import l from"ansi-colors";import{rm as S}from"fs/promises";import{resolve as pe}from"path";import{mergeDeepRight as ce}from"rambda";import{createUnplugin as q}from"unplugin";var U={typesFolder:"@mf-types",deleteTypesFolder:!0},L=t=>{let e=t.split("@");return e[e.length-1]},z=(t,e)=>{let o=L(e),r=new URL(o),s=r.pathname.split("/").slice(0,-1).join("/");return r.pathname=`${s}/${t.typesFolder}.zip`,r.href},W=t=>Object.entries(t.moduleFederationConfig.remotes).reduce((e,[o,r])=>(e[o]=z(t,r),e),{}),T=t=>{if(!t.moduleFederationConfig)throw new Error("moduleFederationConfig is required");let e={...U,...t},o=W(e);return{hostOptions:e,mapRemotesToDownload:o}};import{existsSync as _}from"fs";import{dirname as Z,join as d,resolve as
|
|
2
|
-
export { default } from './${O}';`,f)}}},r},te=t=>I("vue-tsc").createProgram(t),oe=(t,e)=>{switch(t.compilerInstance){case"vue-tsc":return te(e);case"tsc":default:return a.createProgram(e)}},x=(t,e,o)=>{let r=ee(t,e,o),i={rootNames:[...Object.values(t),...o.additionalFilesToCompile],host:r,options:e},p=oe(o,i),{diagnostics:n=[]}=p.emit();n.forEach(Y)};var ie=(t,e)=>P(t.replace(e.typesFolder,""),`${e.typesFolder}.zip`),$=async(t,e)=>{let o=c(t,e),r=new E;return r.addLocalFolder(o),r.writeZipPromise(ie(o,e))},ne=(t,e)=>o=>{throw
|
|
1
|
+
var I=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import l from"ansi-colors";import{rm as S}from"fs/promises";import{resolve as pe}from"path";import{mergeDeepRight as ce}from"rambda";import{createUnplugin as q}from"unplugin";var U={typesFolder:"@mf-types",deleteTypesFolder:!0},L=t=>{let e=t.split("@");return e[e.length-1]},z=(t,e)=>{let o=L(e),r=new URL(o),s=r.pathname.split("/").slice(0,-1).join("/");return r.pathname=`${s}/${t.typesFolder}.zip`,r.href},W=t=>Object.entries(t.moduleFederationConfig.remotes).reduce((e,[o,r])=>(e[o]=z(t,r),e),{}),T=t=>{if(!t.moduleFederationConfig)throw new Error("moduleFederationConfig is required");let e={...U,...t},o=W(e);return{hostOptions:e,mapRemotesToDownload:o}};import{existsSync as _}from"fs";import{dirname as Z,join as d,resolve as k}from"path";import m from"typescript";var M={tsConfigPath:"./tsconfig.json",typesFolder:"@mf-types",compiledTypesFolder:"compiled-types",deleteTypesFolder:!0,additionalFilesToCompile:[],compilerInstance:"tsc"},B=({tsConfigPath:t,typesFolder:e,compiledTypesFolder:o})=>{let r=k(t),s=m.readConfigFile(r,m.sys.readFile),i=m.parseJsonConfigFileContent(s.config,m.sys,Z(r)),p=d(i.options.outDir||"dist",e,o);return{...i.options,emitDeclarationOnly:!0,noEmit:!1,declaration:!0,outDir:p}},X=["ts","tsx","vue","svelte"],R=t=>{let e=process.cwd();for(let o of X){let r=d(e,`${t}.${o}`);if(_(r))return r}},J=t=>Object.entries(t.moduleFederationConfig.exposes).reduce((e,[o,r])=>(e[o]=R(r)||R(d(r,"index"))||r,e),{}),v=t=>{if(!t.moduleFederationConfig)throw new Error("moduleFederationConfig is required");let e={...M,...t},o=J(e);return{tsConfig:B(e),mapComponentsToExpose:o,remoteOptions:e}};import E from"adm-zip";import re from"ansi-colors";import se from"axios";import{join as P}from"path";import C from"ansi-colors";import{dirname as V,join as G,normalize as h,relative as K}from"path";import a from"typescript";var Q=/^\//,F=".d.ts",Y=t=>{let{line:e}=t.file.getLineAndCharacterOfPosition(t.start);console.error(C.red(`TS Error ${t.code}':' ${a.flattenDiagnosticMessageText(t.messageText,a.sys.newLine)}`)),console.error(C.red(` at ${t.file.fileName}:${e+1} typescript.sys.newLine`))},c=(t,e)=>h(t.outDir.replace(e.compiledTypesFolder,"")),w=(t,e)=>h(t.outDir.replace(e.compiledTypesFolder,"").replace(e.typesFolder,"")),ee=(t,e,o)=>{let r=a.createCompilerHost(e),s=r.writeFile,i=Object.fromEntries(Object.entries(t).map(n=>n.reverse())),p=c(e,o);return r.writeFile=(n,D,f,b,u,N)=>{s(n,D,f,b,u,N);for(let j of u||[]){let y=i[j.fileName];if(y){let g=G(p,`${y}${F}`),A=V(g),O=K(A,n).replace(F,"").replace(Q,"");s(g,`export * from './${O}';
|
|
2
|
+
export { default } from './${O}';`,f)}}},r},te=t=>I("vue-tsc").createProgram(t),oe=(t,e)=>{switch(t.compilerInstance){case"vue-tsc":return te(e);case"tsc":default:return a.createProgram(e)}},x=(t,e,o)=>{let r=ee(t,e,o),i={rootNames:[...Object.values(t),...o.additionalFilesToCompile],host:r,options:e},p=oe(o,i),{diagnostics:n=[]}=p.emit();n.forEach(Y)};var ie=(t,e)=>P(t.replace(e.typesFolder,""),`${e.typesFolder}.zip`),$=async(t,e)=>{let o=c(t,e),r=new E;return r.addLocalFolder(o),r.writeZipPromise(ie(o,e))},ne=(t,e)=>o=>{throw o.message=re.red(`Network error: Unable to download federated mocks for '${t}' from '${e}' because '${o.message}', skipping...`),o},H=t=>async([e,o])=>{let r=await se.get(o,{responseType:"arraybuffer"}).catch(ne(e,o)),s=P(t.typesFolder,e);new E(Buffer.from(r.data)).extractAllTo(s,!0)};var Ne=q(t=>{let{remoteOptions:e,tsConfig:o,mapComponentsToExpose:r}=v(t);return{name:"native-federation-typescript/remote",async writeBundle(){try{x(r,o,e),await $(o,e),e.deleteTypesFolder&&await S(c(o,e),{recursive:!0,force:!0}),console.log(l.green("Federated types created correctly"))}catch(s){console.error(l.red(`Unable to compile federated types, ${s}`))}},webpack:s=>{s.options.devServer=ce(s.options.devServer||{},{static:{directory:pe(w(o,e))}})}}}),je=q(t=>{let{hostOptions:e,mapRemotesToDownload:o}=T(t);return{name:"native-federation-typescript/host",async writeBundle(){e.deleteTypesFolder&&await S(e.typesFolder,{recursive:!0,force:!0}).catch(i=>console.error(l.red(`Unable to remove types folder, ${i}`)));let r=H(e),s=Object.entries(o).map(r);await Promise.allSettled(s),console.log(l.green("Federated types extraction completed"))}}});export{Ne as a,je as b};
|
package/dist/esbuild.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP5PXJORBjs = require('./chunk-P5PXJORB.js');var i=_chunkP5PXJORBjs.a.esbuild,r= exports.NativeFederationTypeScriptHost =_chunkP5PXJORBjs.b.esbuild;exports.NativeFederationTypeScriptHost = r; exports.NativeFederationTypeScriptRemote = i;
|
package/dist/esbuild.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t}from"./chunk-
|
|
1
|
+
import{a as e,b as t}from"./chunk-ZPCKDOMT.mjs";var i=e.esbuild,r=t.esbuild;export{r as NativeFederationTypeScriptHost,i as NativeFederationTypeScriptRemote};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP5PXJORBjs = require('./chunk-P5PXJORB.js');exports.NativeFederationTypeScriptHost = _chunkP5PXJORBjs.b; exports.NativeFederationTypeScriptRemote = _chunkP5PXJORBjs.a;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-ZPCKDOMT.mjs";export{b as NativeFederationTypeScriptHost,a as NativeFederationTypeScriptRemote};
|
package/dist/rollup.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { R as RemoteOptions, H as HostOptions } from './RemoteOptions-ce85caac.js';
|
|
2
2
|
|
|
3
|
-
declare const NativeFederationTypeScriptRemote: (options: RemoteOptions) => undefined | undefined[];
|
|
4
|
-
declare const NativeFederationTypeScriptHost: (options: HostOptions) => undefined | undefined[];
|
|
3
|
+
declare const NativeFederationTypeScriptRemote: (options: RemoteOptions) => undefined<any> | undefined<any>[];
|
|
4
|
+
declare const NativeFederationTypeScriptHost: (options: HostOptions) => undefined<any> | undefined<any>[];
|
|
5
5
|
|
|
6
6
|
export { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { R as RemoteOptions, H as HostOptions } from './RemoteOptions-ce85caac.js';
|
|
2
2
|
|
|
3
|
-
declare const NativeFederationTypeScriptRemote: (options: RemoteOptions) => undefined | undefined[];
|
|
4
|
-
declare const NativeFederationTypeScriptHost: (options: HostOptions) => undefined | undefined[];
|
|
3
|
+
declare const NativeFederationTypeScriptRemote: (options: RemoteOptions) => undefined<any> | undefined<any>[];
|
|
4
|
+
declare const NativeFederationTypeScriptHost: (options: HostOptions) => undefined<any> | undefined<any>[];
|
|
5
5
|
|
|
6
6
|
export { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote };
|
package/dist/rollup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP5PXJORBjs = require('./chunk-P5PXJORB.js');var r=_chunkP5PXJORBjs.a.rollup,i= exports.NativeFederationTypeScriptHost =_chunkP5PXJORBjs.b.rollup;exports.NativeFederationTypeScriptHost = i; exports.NativeFederationTypeScriptRemote = r;
|
package/dist/rollup.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t}from"./chunk-
|
|
1
|
+
import{a as e,b as t}from"./chunk-ZPCKDOMT.mjs";var r=e.rollup,i=t.rollup;export{i as NativeFederationTypeScriptHost,r as NativeFederationTypeScriptRemote};
|
package/dist/rspack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP5PXJORBjs = require('./chunk-P5PXJORB.js');var r=_chunkP5PXJORBjs.a.rspack,a= exports.NativeFederationTypeScriptHost =_chunkP5PXJORBjs.b.rspack;exports.NativeFederationTypeScriptHost = a; exports.NativeFederationTypeScriptRemote = r;
|
package/dist/rspack.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t}from"./chunk-
|
|
1
|
+
import{a as e,b as t}from"./chunk-ZPCKDOMT.mjs";var r=e.rspack,a=t.rspack;export{a as NativeFederationTypeScriptHost,r as NativeFederationTypeScriptRemote};
|
package/dist/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP5PXJORBjs = require('./chunk-P5PXJORB.js');var i=_chunkP5PXJORBjs.a.vite,p= exports.NativeFederationTypeScriptHost =_chunkP5PXJORBjs.b.vite;exports.NativeFederationTypeScriptHost = p; exports.NativeFederationTypeScriptRemote = i;
|
package/dist/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,b as e}from"./chunk-
|
|
1
|
+
import{a as t,b as e}from"./chunk-ZPCKDOMT.mjs";var i=t.vite,p=e.vite;export{p as NativeFederationTypeScriptHost,i as NativeFederationTypeScriptRemote};
|
package/dist/webpack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP5PXJORBjs = require('./chunk-P5PXJORB.js');var a=_chunkP5PXJORBjs.a.webpack,r= exports.NativeFederationTypeScriptHost =_chunkP5PXJORBjs.b.webpack;exports.NativeFederationTypeScriptHost = r; exports.NativeFederationTypeScriptRemote = a;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t}from"./chunk-
|
|
1
|
+
import{a as e,b as t}from"./chunk-ZPCKDOMT.mjs";var a=e.webpack,r=t.webpack;export{r as NativeFederationTypeScriptHost,a as NativeFederationTypeScriptRemote};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/native-federation-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-canary.1",
|
|
4
4
|
"description": "Bundler agnostic unplugin to share federated types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"module federation",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"federated types"
|
|
10
10
|
],
|
|
11
11
|
"publishConfig": {
|
|
12
|
-
"
|
|
12
|
+
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|