@module-federation/third-party-dts-extractor 0.0.0-docs-remove-invalid-lark-link-20251205062649

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,273 @@
1
+ # @module-federation/third-party-dts-extractor
2
+
3
+ ## 0.0.0-docs-remove-invalid-lark-link-20251205062649
4
+
5
+ ## 0.21.6
6
+
7
+ ## 0.21.5
8
+
9
+ ## 0.21.4
10
+
11
+ ## 0.21.3
12
+
13
+ ## 0.21.2
14
+
15
+ ## 0.21.1
16
+
17
+ ## 0.21.0
18
+
19
+ ## 0.20.0
20
+
21
+ ## 0.19.1
22
+
23
+ ## 0.19.0
24
+
25
+ ## 0.18.4
26
+
27
+ ## 0.18.3
28
+
29
+ ## 0.18.2
30
+
31
+ ## 0.18.1
32
+
33
+ ## 0.18.0
34
+
35
+ ## 0.17.1
36
+
37
+ ### Patch Changes
38
+
39
+ - a7cf276: chore: upgrade NX to 21.2.3, Storybook to 9.0.9, and TypeScript to 5.8.3
40
+
41
+ - Upgraded NX from 21.0.3 to 21.2.3 with workspace configuration updates
42
+ - Migrated Storybook from 8.3.5 to 9.0.9 with updated configurations and automigrations
43
+ - Upgraded TypeScript from 5.7.3 to 5.8.3 with compatibility fixes
44
+ - Fixed package exports and type declaration paths across all packages
45
+ - Resolved module resolution issues and TypeScript compatibility problems
46
+ - Updated build configurations and dependencies to support latest versions
47
+
48
+ - d31a326: refactor: sink React packages from root to individual packages
49
+
50
+ - Removed React dependencies from root package.json and moved them to packages that actually need them
51
+ - Fixed rsbuild-plugin configuration to match workspace patterns
52
+ - Updated tests to handle platform-specific files
53
+ - This change improves dependency management by ensuring packages only have the dependencies they actually use
54
+
55
+ ## 0.17.0
56
+
57
+ ## 0.16.0
58
+
59
+ ## 0.15.0
60
+
61
+ ## 0.14.3
62
+
63
+ ## 0.14.2
64
+
65
+ ## 0.14.1
66
+
67
+ ## 0.14.0
68
+
69
+ ## 0.13.1
70
+
71
+ ### Patch Changes
72
+
73
+ - 723d0f8: fix(third-party-dts-extractor): correctly sets the source of the package types
74
+
75
+ ## 0.13.0
76
+
77
+ ### Patch Changes
78
+
79
+ - 38f324f: Disable live bindings on cjs builds of the runtime packages
80
+
81
+ ## 0.12.0
82
+
83
+ ### Patch Changes
84
+
85
+ - ef96c4d: feat(dts-plugin): support exclude extract specify third party dts
86
+
87
+ ## 0.11.4
88
+
89
+ ## 0.11.3
90
+
91
+ ## 0.11.2
92
+
93
+ ## 0.11.1
94
+
95
+ ## 0.11.0
96
+
97
+ ## 0.10.0
98
+
99
+ ## 0.9.1
100
+
101
+ ## 0.9.0
102
+
103
+ ## 0.8.12
104
+
105
+ ## 0.8.11
106
+
107
+ ## 0.8.10
108
+
109
+ ## 0.8.9
110
+
111
+ ## 0.8.8
112
+
113
+ ## 0.8.7
114
+
115
+ ## 0.8.6
116
+
117
+ ## 0.8.5
118
+
119
+ ## 0.8.4
120
+
121
+ ## 0.8.3
122
+
123
+ ## 0.8.2
124
+
125
+ ## 0.8.1
126
+
127
+ ## 0.8.0
128
+
129
+ ## 0.7.7
130
+
131
+ ## 0.7.6
132
+
133
+ ## 0.7.5
134
+
135
+ ## 0.7.4
136
+
137
+ ## 0.7.3
138
+
139
+ ## 0.7.2
140
+
141
+ ## 0.7.1
142
+
143
+ ## 0.7.0
144
+
145
+ ## 0.6.16
146
+
147
+ ## 0.6.15
148
+
149
+ ## 0.6.14
150
+
151
+ ## 0.6.13
152
+
153
+ ## 0.6.12
154
+
155
+ ## 0.6.11
156
+
157
+ ## 0.6.10
158
+
159
+ ## 0.6.9
160
+
161
+ ## 0.6.8
162
+
163
+ ## 0.6.7
164
+
165
+ ## 0.6.6
166
+
167
+ ## 0.6.5
168
+
169
+ ## 0.6.4
170
+
171
+ ## 0.6.3
172
+
173
+ ## 0.6.2
174
+
175
+ ## 0.6.1
176
+
177
+ ## 0.6.0
178
+
179
+ ## 0.5.2
180
+
181
+ ## 0.5.1
182
+
183
+ ## 0.5.0
184
+
185
+ ## 0.4.0
186
+
187
+ ## 0.3.5
188
+
189
+ ## 0.3.4
190
+
191
+ ## 0.3.3
192
+
193
+ ## 0.3.2
194
+
195
+ ### Patch Changes
196
+
197
+ - 0de1c83: fix: do not collect node internal utils
198
+
199
+ ## 0.3.1
200
+
201
+ ## 0.3.0
202
+
203
+ ## 0.2.8
204
+
205
+ ## 0.2.7
206
+
207
+ ### Patch Changes
208
+
209
+ - b00ef13: fix(dts-plugin): support compile vue@3 dts
210
+
211
+ ## 0.2.6
212
+
213
+ ## 0.2.5
214
+
215
+ ## 0.2.4
216
+
217
+ ## 0.2.3
218
+
219
+ ## 0.2.2
220
+
221
+ ## 0.2.1
222
+
223
+ ## 0.2.0
224
+
225
+ ## 0.1.21
226
+
227
+ ## 0.1.20
228
+
229
+ ### Patch Changes
230
+
231
+ - 685c607: feat: support dynamic remote type hints
232
+
233
+ ## 0.1.19
234
+
235
+ ## 0.1.18
236
+
237
+ ## 0.1.17
238
+
239
+ ## 0.1.16
240
+
241
+ ## 0.1.15
242
+
243
+ ## 0.1.14
244
+
245
+ ## 0.1.13
246
+
247
+ ### Patch Changes
248
+
249
+ - 677958c: fix: tsup configuration
250
+
251
+ ## 0.1.12
252
+
253
+ ## 0.1.11
254
+
255
+ ## 0.1.10
256
+
257
+ ## 0.1.9
258
+
259
+ ## 0.1.8
260
+
261
+ ## 0.1.7
262
+
263
+ ## 0.1.6
264
+
265
+ ### Patch Changes
266
+
267
+ - 72c7b80: chore: fix release tag
268
+
269
+ ## 0.0.18
270
+
271
+ ### Patch Changes
272
+
273
+ - 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-docs-remove-invalid-lark-link-20251205062649",
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-docs-remove-invalid-lark-link-20251205062649",
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
+ }