@module-federation/third-party-dts-extractor 0.0.0-feat-support-bridge-react-router-v7-20251015102312

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present zhanghang(2heal1)
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 ADDED
@@ -0,0 +1 @@
1
+ # @module-federation/third-party-dts-extractor
@@ -0,0 +1,259 @@
1
+ # @module-federation/third-party-dts-extractor
2
+
3
+ ## 0.0.0-feat-support-bridge-react-router-v7-20251015102312
4
+
5
+ ## 0.20.0
6
+
7
+ ## 0.19.1
8
+
9
+ ## 0.19.0
10
+
11
+ ## 0.18.4
12
+
13
+ ## 0.18.3
14
+
15
+ ## 0.18.2
16
+
17
+ ## 0.18.1
18
+
19
+ ## 0.18.0
20
+
21
+ ## 0.17.1
22
+
23
+ ### Patch Changes
24
+
25
+ - a7cf276: chore: upgrade NX to 21.2.3, Storybook to 9.0.9, and TypeScript to 5.8.3
26
+
27
+ - Upgraded NX from 21.0.3 to 21.2.3 with workspace configuration updates
28
+ - Migrated Storybook from 8.3.5 to 9.0.9 with updated configurations and automigrations
29
+ - Upgraded TypeScript from 5.7.3 to 5.8.3 with compatibility fixes
30
+ - Fixed package exports and type declaration paths across all packages
31
+ - Resolved module resolution issues and TypeScript compatibility problems
32
+ - Updated build configurations and dependencies to support latest versions
33
+
34
+ - d31a326: refactor: sink React packages from root to individual packages
35
+
36
+ - Removed React dependencies from root package.json and moved them to packages that actually need them
37
+ - Fixed rsbuild-plugin configuration to match workspace patterns
38
+ - Updated tests to handle platform-specific files
39
+ - This change improves dependency management by ensuring packages only have the dependencies they actually use
40
+
41
+ ## 0.17.0
42
+
43
+ ## 0.16.0
44
+
45
+ ## 0.15.0
46
+
47
+ ## 0.14.3
48
+
49
+ ## 0.14.2
50
+
51
+ ## 0.14.1
52
+
53
+ ## 0.14.0
54
+
55
+ ## 0.13.1
56
+
57
+ ### Patch Changes
58
+
59
+ - 723d0f8: fix(third-party-dts-extractor): correctly sets the source of the package types
60
+
61
+ ## 0.13.0
62
+
63
+ ### Patch Changes
64
+
65
+ - 38f324f: Disable live bindings on cjs builds of the runtime packages
66
+
67
+ ## 0.12.0
68
+
69
+ ### Patch Changes
70
+
71
+ - ef96c4d: feat(dts-plugin): support exclude extract specify third party dts
72
+
73
+ ## 0.11.4
74
+
75
+ ## 0.11.3
76
+
77
+ ## 0.11.2
78
+
79
+ ## 0.11.1
80
+
81
+ ## 0.11.0
82
+
83
+ ## 0.10.0
84
+
85
+ ## 0.9.1
86
+
87
+ ## 0.9.0
88
+
89
+ ## 0.8.12
90
+
91
+ ## 0.8.11
92
+
93
+ ## 0.8.10
94
+
95
+ ## 0.8.9
96
+
97
+ ## 0.8.8
98
+
99
+ ## 0.8.7
100
+
101
+ ## 0.8.6
102
+
103
+ ## 0.8.5
104
+
105
+ ## 0.8.4
106
+
107
+ ## 0.8.3
108
+
109
+ ## 0.8.2
110
+
111
+ ## 0.8.1
112
+
113
+ ## 0.8.0
114
+
115
+ ## 0.7.7
116
+
117
+ ## 0.7.6
118
+
119
+ ## 0.7.5
120
+
121
+ ## 0.7.4
122
+
123
+ ## 0.7.3
124
+
125
+ ## 0.7.2
126
+
127
+ ## 0.7.1
128
+
129
+ ## 0.7.0
130
+
131
+ ## 0.6.16
132
+
133
+ ## 0.6.15
134
+
135
+ ## 0.6.14
136
+
137
+ ## 0.6.13
138
+
139
+ ## 0.6.12
140
+
141
+ ## 0.6.11
142
+
143
+ ## 0.6.10
144
+
145
+ ## 0.6.9
146
+
147
+ ## 0.6.8
148
+
149
+ ## 0.6.7
150
+
151
+ ## 0.6.6
152
+
153
+ ## 0.6.5
154
+
155
+ ## 0.6.4
156
+
157
+ ## 0.6.3
158
+
159
+ ## 0.6.2
160
+
161
+ ## 0.6.1
162
+
163
+ ## 0.6.0
164
+
165
+ ## 0.5.2
166
+
167
+ ## 0.5.1
168
+
169
+ ## 0.5.0
170
+
171
+ ## 0.4.0
172
+
173
+ ## 0.3.5
174
+
175
+ ## 0.3.4
176
+
177
+ ## 0.3.3
178
+
179
+ ## 0.3.2
180
+
181
+ ### Patch Changes
182
+
183
+ - 0de1c83: fix: do not collect node internal utils
184
+
185
+ ## 0.3.1
186
+
187
+ ## 0.3.0
188
+
189
+ ## 0.2.8
190
+
191
+ ## 0.2.7
192
+
193
+ ### Patch Changes
194
+
195
+ - b00ef13: fix(dts-plugin): support compile vue@3 dts
196
+
197
+ ## 0.2.6
198
+
199
+ ## 0.2.5
200
+
201
+ ## 0.2.4
202
+
203
+ ## 0.2.3
204
+
205
+ ## 0.2.2
206
+
207
+ ## 0.2.1
208
+
209
+ ## 0.2.0
210
+
211
+ ## 0.1.21
212
+
213
+ ## 0.1.20
214
+
215
+ ### Patch Changes
216
+
217
+ - 685c607: feat: support dynamic remote type hints
218
+
219
+ ## 0.1.19
220
+
221
+ ## 0.1.18
222
+
223
+ ## 0.1.17
224
+
225
+ ## 0.1.16
226
+
227
+ ## 0.1.15
228
+
229
+ ## 0.1.14
230
+
231
+ ## 0.1.13
232
+
233
+ ### Patch Changes
234
+
235
+ - 677958c: fix: tsup configuration
236
+
237
+ ## 0.1.12
238
+
239
+ ## 0.1.11
240
+
241
+ ## 0.1.10
242
+
243
+ ## 0.1.9
244
+
245
+ ## 0.1.8
246
+
247
+ ## 0.1.7
248
+
249
+ ## 0.1.6
250
+
251
+ ### Patch Changes
252
+
253
+ - 72c7b80: chore: fix release tag
254
+
255
+ ## 0.0.18
256
+
257
+ ### Patch Changes
258
+
259
+ - c8c0ad2: feat: enhance type capability
package/dist/README.md ADDED
@@ -0,0 +1 @@
1
+ # @module-federation/third-party-dts-extractor
@@ -0,0 +1,20 @@
1
+ type ThirdPartyExtractorOptions = {
2
+ destDir: string;
3
+ context?: string;
4
+ exclude?: Array<string | RegExp>;
5
+ };
6
+ declare class ThirdPartyExtractor {
7
+ pkgs: Record<string, string>;
8
+ pattern: RegExp;
9
+ context: string;
10
+ destDir: string;
11
+ exclude: Array<string | RegExp>;
12
+ constructor({ destDir, context, exclude, }: ThirdPartyExtractorOptions);
13
+ addPkgs(pkgName: string, dirName: string): void;
14
+ inferPkgDir(importPath: string): string | void;
15
+ collectTypeImports(str: string): string[];
16
+ collectPkgs(str: string): void;
17
+ copyDts(): Promise<void>;
18
+ }
19
+
20
+ export { ThirdPartyExtractor };
@@ -0,0 +1,20 @@
1
+ type ThirdPartyExtractorOptions = {
2
+ destDir: string;
3
+ context?: string;
4
+ exclude?: Array<string | RegExp>;
5
+ };
6
+ declare class ThirdPartyExtractor {
7
+ pkgs: Record<string, string>;
8
+ pattern: RegExp;
9
+ context: string;
10
+ destDir: string;
11
+ exclude: Array<string | RegExp>;
12
+ constructor({ destDir, context, exclude, }: ThirdPartyExtractorOptions);
13
+ addPkgs(pkgName: string, dirName: string): void;
14
+ inferPkgDir(importPath: string): string | void;
15
+ collectTypeImports(str: string): string[];
16
+ collectPkgs(str: string): void;
17
+ copyDts(): Promise<void>;
18
+ }
19
+
20
+ export { ThirdPartyExtractor };
package/dist/index.js ADDED
@@ -0,0 +1,210 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
10
+ var _findpkg = require('find-pkg'); var _findpkg2 = _interopRequireDefault(_findpkg);
11
+ var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
12
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
13
+ var _resolve = require('resolve'); var _resolve2 = _interopRequireDefault(_resolve);
14
+
15
+ // packages/third-party-dts-extractor/src/utils.ts
16
+
17
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
18
+ function getTypedName(name) {
19
+ return `@types/${name.replace(/^@/, "").replace("/", "__")}`;
20
+ }
21
+ function getPackageRootDir(packageName) {
22
+ if (!packageName) {
23
+ throw new Error("No package name provided.");
24
+ }
25
+ const entryFile = __require.resolve(packageName);
26
+ const entryDir = _path2.default.dirname(entryFile);
27
+ let fallbackPackageJsonPath = _path2.default.join(
28
+ entryDir,
29
+ "package.json"
30
+ );
31
+ if (!_fs2.default.existsSync(fallbackPackageJsonPath)) {
32
+ fallbackPackageJsonPath = null;
33
+ }
34
+ const match = packageName.match(/^@[^/]+\/(.+)$/);
35
+ const localName = match ? match[1] : packageName;
36
+ let currentDir = entryDir;
37
+ while (_path2.default.basename(currentDir) !== localName && // Keep going if names differ
38
+ _path2.default.dirname(currentDir) !== currentDir) {
39
+ try {
40
+ currentDir = _path2.default.dirname(currentDir);
41
+ } catch (err) {
42
+ if (err.code === "EACCES") {
43
+ continue;
44
+ } else {
45
+ throw err;
46
+ }
47
+ }
48
+ }
49
+ if (_path2.default.basename(currentDir) === localName) {
50
+ const candidate = _path2.default.join(currentDir, "package.json");
51
+ if (_fs2.default.existsSync(candidate)) {
52
+ const pkgContent = JSON.parse(_fs2.default.readFileSync(candidate, "utf8"));
53
+ if (pkgContent.name === packageName) {
54
+ return currentDir;
55
+ }
56
+ }
57
+ }
58
+ if (fallbackPackageJsonPath) {
59
+ return entryDir;
60
+ }
61
+ throw new Error(
62
+ `Could not find a matching package.json for "${packageName}" and no fallback was found.`
63
+ );
64
+ }
65
+
66
+ // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
67
+ var ignoredPkgs = ["typescript"];
68
+ var isNodeUtils = (pkgJsonPath, importPath) => {
69
+ return pkgJsonPath === importPath;
70
+ };
71
+ var ThirdPartyExtractor = class {
72
+ constructor({
73
+ destDir,
74
+ context = process.cwd(),
75
+ exclude = []
76
+ }) {
77
+ this.destDir = destDir;
78
+ this.context = context;
79
+ this.pkgs = {};
80
+ this.pattern = /(from|import\()\s*['"]([^'"]+)['"]/g;
81
+ this.exclude = exclude;
82
+ }
83
+ addPkgs(pkgName, dirName) {
84
+ if (ignoredPkgs.includes(pkgName)) {
85
+ return;
86
+ }
87
+ if (this.exclude.some((pattern) => {
88
+ if (typeof pattern === "string") {
89
+ return new RegExp(pattern).test(pkgName);
90
+ } else {
91
+ return pattern.test(pkgName);
92
+ }
93
+ })) {
94
+ return;
95
+ }
96
+ this.pkgs[pkgName] = dirName;
97
+ }
98
+ inferPkgDir(importPath) {
99
+ if (this.pkgs[importPath]) {
100
+ return;
101
+ }
102
+ if (_path2.default.isAbsolute(importPath)) {
103
+ return;
104
+ }
105
+ if (importPath.startsWith(".")) {
106
+ return;
107
+ }
108
+ try {
109
+ const importEntry = __require.resolve(importPath, {
110
+ paths: [this.context]
111
+ });
112
+ if (isNodeUtils(importEntry, importPath)) {
113
+ return;
114
+ }
115
+ const packageDir = getPackageRootDir(importPath);
116
+ const pkgJsonPath = _path2.default.join(packageDir, "package.json");
117
+ const dir = _path2.default.dirname(pkgJsonPath);
118
+ const pkg = JSON.parse(_fsextra2.default.readFileSync(pkgJsonPath, "utf-8"));
119
+ const types = pkg.types || pkg.typings;
120
+ if (dir === this.context) {
121
+ return;
122
+ }
123
+ if (types) {
124
+ const typesDir = _path2.default.dirname(_path2.default.resolve(dir, types));
125
+ this.addPkgs(pkg.name, typesDir);
126
+ return typesDir;
127
+ } else if (_fsextra2.default.existsSync(_path2.default.resolve(dir, "index.d.ts"))) {
128
+ this.addPkgs(pkg.name, dir);
129
+ return dir;
130
+ } else {
131
+ const typedPkgName = getTypedName(pkg.name);
132
+ const typedPkgJsonPath = _findpkg2.default.sync(
133
+ _resolve2.default.sync(`${typedPkgName}/package.json`, {
134
+ basedir: this.context
135
+ })
136
+ );
137
+ const typedDir = _path2.default.dirname(typedPkgJsonPath);
138
+ _fsextra2.default.readFileSync(typedPkgJsonPath, "utf-8");
139
+ this.addPkgs(typedPkgName, typedDir);
140
+ return typedDir;
141
+ }
142
+ } catch (_err) {
143
+ return;
144
+ }
145
+ }
146
+ collectTypeImports(str) {
147
+ const { pattern } = this;
148
+ let match;
149
+ const imports = /* @__PURE__ */ new Set();
150
+ while ((match = pattern.exec(str)) !== null) {
151
+ imports.add(match[2]);
152
+ }
153
+ return [...imports];
154
+ }
155
+ collectPkgs(str) {
156
+ const imports = this.collectTypeImports(str);
157
+ imports.forEach((importPath) => {
158
+ this.inferPkgDir(importPath);
159
+ });
160
+ }
161
+ async copyDts() {
162
+ if (!Object.keys(this.pkgs).length) {
163
+ return;
164
+ }
165
+ const ensureDir = async (dir) => {
166
+ try {
167
+ await _fsextra2.default.mkdir(dir, { recursive: true });
168
+ } catch (err) {
169
+ if (err.code !== "EEXIST")
170
+ throw err;
171
+ }
172
+ };
173
+ const copyFiles = async (srcDir, destDir) => {
174
+ if (srcDir.startsWith(".")) {
175
+ return;
176
+ }
177
+ const files = await _fsextra2.default.readdir(srcDir);
178
+ await Promise.all(
179
+ files.map(async (file) => {
180
+ const fullPath = _path2.default.join(srcDir, file);
181
+ if (["node_modules", "bin"].includes(file)) {
182
+ return;
183
+ }
184
+ const stats = await _fsextra2.default.lstat(fullPath);
185
+ if (stats.isDirectory()) {
186
+ const destFullPath = _path2.default.join(destDir, file);
187
+ await ensureDir(destFullPath);
188
+ await copyFiles(fullPath, destFullPath);
189
+ } else {
190
+ if (fullPath.endsWith(".d.ts") || fullPath.endsWith("package.json")) {
191
+ await _fsextra2.default.copyFile(fullPath, _path2.default.join(destDir, file));
192
+ }
193
+ }
194
+ })
195
+ );
196
+ };
197
+ await ensureDir(this.destDir);
198
+ await Promise.all(
199
+ Object.keys(this.pkgs).map(async (pkgName) => {
200
+ const pkgDir = this.pkgs[pkgName];
201
+ const destDir = _path2.default.resolve(this.destDir, pkgName);
202
+ await ensureDir(destDir);
203
+ await copyFiles(pkgDir, destDir);
204
+ })
205
+ );
206
+ }
207
+ };
208
+
209
+
210
+ exports.ThirdPartyExtractor = ThirdPartyExtractor;
package/dist/index.mjs ADDED
@@ -0,0 +1,210 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
10
+ import findPkg from "find-pkg";
11
+ import fs2 from "fs-extra";
12
+ import path2 from "path";
13
+ import resolve from "resolve";
14
+
15
+ // packages/third-party-dts-extractor/src/utils.ts
16
+ import path from "node:path";
17
+ import fs from "node:fs";
18
+ function getTypedName(name) {
19
+ return `@types/${name.replace(/^@/, "").replace("/", "__")}`;
20
+ }
21
+ function getPackageRootDir(packageName) {
22
+ if (!packageName) {
23
+ throw new Error("No package name provided.");
24
+ }
25
+ const entryFile = __require.resolve(packageName);
26
+ const entryDir = path.dirname(entryFile);
27
+ let fallbackPackageJsonPath = path.join(
28
+ entryDir,
29
+ "package.json"
30
+ );
31
+ if (!fs.existsSync(fallbackPackageJsonPath)) {
32
+ fallbackPackageJsonPath = null;
33
+ }
34
+ const match = packageName.match(/^@[^/]+\/(.+)$/);
35
+ const localName = match ? match[1] : packageName;
36
+ let currentDir = entryDir;
37
+ while (path.basename(currentDir) !== localName && // Keep going if names differ
38
+ path.dirname(currentDir) !== currentDir) {
39
+ try {
40
+ currentDir = path.dirname(currentDir);
41
+ } catch (err) {
42
+ if (err.code === "EACCES") {
43
+ continue;
44
+ } else {
45
+ throw err;
46
+ }
47
+ }
48
+ }
49
+ if (path.basename(currentDir) === localName) {
50
+ const candidate = path.join(currentDir, "package.json");
51
+ if (fs.existsSync(candidate)) {
52
+ const pkgContent = JSON.parse(fs.readFileSync(candidate, "utf8"));
53
+ if (pkgContent.name === packageName) {
54
+ return currentDir;
55
+ }
56
+ }
57
+ }
58
+ if (fallbackPackageJsonPath) {
59
+ return entryDir;
60
+ }
61
+ throw new Error(
62
+ `Could not find a matching package.json for "${packageName}" and no fallback was found.`
63
+ );
64
+ }
65
+
66
+ // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
67
+ var ignoredPkgs = ["typescript"];
68
+ var isNodeUtils = (pkgJsonPath, importPath) => {
69
+ return pkgJsonPath === importPath;
70
+ };
71
+ var ThirdPartyExtractor = class {
72
+ constructor({
73
+ destDir,
74
+ context = process.cwd(),
75
+ exclude = []
76
+ }) {
77
+ this.destDir = destDir;
78
+ this.context = context;
79
+ this.pkgs = {};
80
+ this.pattern = /(from|import\()\s*['"]([^'"]+)['"]/g;
81
+ this.exclude = exclude;
82
+ }
83
+ addPkgs(pkgName, dirName) {
84
+ if (ignoredPkgs.includes(pkgName)) {
85
+ return;
86
+ }
87
+ if (this.exclude.some((pattern) => {
88
+ if (typeof pattern === "string") {
89
+ return new RegExp(pattern).test(pkgName);
90
+ } else {
91
+ return pattern.test(pkgName);
92
+ }
93
+ })) {
94
+ return;
95
+ }
96
+ this.pkgs[pkgName] = dirName;
97
+ }
98
+ inferPkgDir(importPath) {
99
+ if (this.pkgs[importPath]) {
100
+ return;
101
+ }
102
+ if (path2.isAbsolute(importPath)) {
103
+ return;
104
+ }
105
+ if (importPath.startsWith(".")) {
106
+ return;
107
+ }
108
+ try {
109
+ const importEntry = __require.resolve(importPath, {
110
+ paths: [this.context]
111
+ });
112
+ if (isNodeUtils(importEntry, importPath)) {
113
+ return;
114
+ }
115
+ const packageDir = getPackageRootDir(importPath);
116
+ const pkgJsonPath = path2.join(packageDir, "package.json");
117
+ const dir = path2.dirname(pkgJsonPath);
118
+ const pkg = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
119
+ const types = pkg.types || pkg.typings;
120
+ if (dir === this.context) {
121
+ return;
122
+ }
123
+ if (types) {
124
+ const typesDir = path2.dirname(path2.resolve(dir, types));
125
+ this.addPkgs(pkg.name, typesDir);
126
+ return typesDir;
127
+ } else if (fs2.existsSync(path2.resolve(dir, "index.d.ts"))) {
128
+ this.addPkgs(pkg.name, dir);
129
+ return dir;
130
+ } else {
131
+ const typedPkgName = getTypedName(pkg.name);
132
+ const typedPkgJsonPath = findPkg.sync(
133
+ resolve.sync(`${typedPkgName}/package.json`, {
134
+ basedir: this.context
135
+ })
136
+ );
137
+ const typedDir = path2.dirname(typedPkgJsonPath);
138
+ fs2.readFileSync(typedPkgJsonPath, "utf-8");
139
+ this.addPkgs(typedPkgName, typedDir);
140
+ return typedDir;
141
+ }
142
+ } catch (_err) {
143
+ return;
144
+ }
145
+ }
146
+ collectTypeImports(str) {
147
+ const { pattern } = this;
148
+ let match;
149
+ const imports = /* @__PURE__ */ new Set();
150
+ while ((match = pattern.exec(str)) !== null) {
151
+ imports.add(match[2]);
152
+ }
153
+ return [...imports];
154
+ }
155
+ collectPkgs(str) {
156
+ const imports = this.collectTypeImports(str);
157
+ imports.forEach((importPath) => {
158
+ this.inferPkgDir(importPath);
159
+ });
160
+ }
161
+ async copyDts() {
162
+ if (!Object.keys(this.pkgs).length) {
163
+ return;
164
+ }
165
+ const ensureDir = async (dir) => {
166
+ try {
167
+ await fs2.mkdir(dir, { recursive: true });
168
+ } catch (err) {
169
+ if (err.code !== "EEXIST")
170
+ throw err;
171
+ }
172
+ };
173
+ const copyFiles = async (srcDir, destDir) => {
174
+ if (srcDir.startsWith(".")) {
175
+ return;
176
+ }
177
+ const files = await fs2.readdir(srcDir);
178
+ await Promise.all(
179
+ files.map(async (file) => {
180
+ const fullPath = path2.join(srcDir, file);
181
+ if (["node_modules", "bin"].includes(file)) {
182
+ return;
183
+ }
184
+ const stats = await fs2.lstat(fullPath);
185
+ if (stats.isDirectory()) {
186
+ const destFullPath = path2.join(destDir, file);
187
+ await ensureDir(destFullPath);
188
+ await copyFiles(fullPath, destFullPath);
189
+ } else {
190
+ if (fullPath.endsWith(".d.ts") || fullPath.endsWith("package.json")) {
191
+ await fs2.copyFile(fullPath, path2.join(destDir, file));
192
+ }
193
+ }
194
+ })
195
+ );
196
+ };
197
+ await ensureDir(this.destDir);
198
+ await Promise.all(
199
+ Object.keys(this.pkgs).map(async (pkgName) => {
200
+ const pkgDir = this.pkgs[pkgName];
201
+ const destDir = path2.resolve(this.destDir, pkgName);
202
+ await ensureDir(destDir);
203
+ await copyFiles(pkgDir, destDir);
204
+ })
205
+ );
206
+ }
207
+ };
208
+ export {
209
+ ThirdPartyExtractor
210
+ };
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@module-federation/third-party-dts-extractor",
3
+ "version": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
4
+ "files": [
5
+ "dist/",
6
+ "README.md"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/module-federation/core.git",
11
+ "directory": "packages/third-party-dts-extractor"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.js"
21
+ }
22
+ },
23
+ "typesVersions": {
24
+ "*": {
25
+ ".": [
26
+ "./dist/index.d.ts"
27
+ ]
28
+ }
29
+ },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "author": "hanric <hanric.zhang@gmail.com>",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "find-pkg": "2.0.0",
36
+ "fs-extra": "9.1.0",
37
+ "resolve": "1.22.8"
38
+ },
39
+ "devDependencies": {
40
+ "@types/react": "^18.3.11"
41
+ }
42
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@module-federation/third-party-dts-extractor",
3
+ "version": "0.0.0-feat-support-bridge-react-router-v7-20251015102312",
4
+ "files": [
5
+ "dist/",
6
+ "README.md"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/module-federation/core.git",
11
+ "directory": "packages/third-party-dts-extractor"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.js"
21
+ }
22
+ },
23
+ "typesVersions": {
24
+ "*": {
25
+ ".": [
26
+ "./dist/index.d.ts"
27
+ ]
28
+ }
29
+ },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "author": "hanric <hanric.zhang@gmail.com>",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "find-pkg": "2.0.0",
36
+ "fs-extra": "9.1.0",
37
+ "resolve": "1.22.8"
38
+ },
39
+ "devDependencies": {
40
+ "@types/react": "^18.3.11"
41
+ }
42
+ }