@module-federation/third-party-dts-extractor 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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/dist/CHANGELOG.md CHANGED
@@ -1,6 +1,64 @@
1
1
  # @module-federation/third-party-dts-extractor
2
2
 
3
- ## 0.0.0-perf-devtools-20260107043700
3
+ ## 0.0.0-perf-website-code-usage-20260914033703
4
+
5
+ ## 2.9.0
6
+
7
+ ## 2.8.2
8
+
9
+ ## 2.8.1
10
+
11
+ ## 2.8.0
12
+
13
+ ### Patch Changes
14
+
15
+ - 6ee67dc: Reduce installed and bundled size by replacing general-purpose cache, path, version, package lookup, scheduling, fetch, and error fallback dependencies with focused built-in utilities.
16
+
17
+ ## 2.7.0
18
+
19
+ ### Patch Changes
20
+
21
+ - 2add9ef: chore(third-party-dts-extractor): replace `resolve` with `exsolve` (0 transitive deps, ~100KB smaller) for the single `package.json` lookup.
22
+ - a5f123a: chore: replace `find-pkg` with `empathic` (per [e18e replacements](https://e18e.dev/docs/replacements/find-pkg.html)). Removes unused `find-pkg` dependency from `@module-federation/manifest`.
23
+ - 8ec950c: Bump runtime dependencies: echarts 6.1.0 (devtools), hono 4.12.26 and @hono/node-server 1.19.13 (treeshake-server), lodash-es 4.18.1 (rspress-plugin), handlebars 4.7.9 (create-module-federation), resolve 1.22.12 (third-party-dts-extractor).
24
+
25
+ ## 2.6.0
26
+
27
+ ## 2.5.1
28
+
29
+ ## 2.5.0
30
+
31
+ ## 2.4.0
32
+
33
+ ## 2.3.3
34
+
35
+ ## 2.3.2
36
+
37
+ ## 2.3.1
38
+
39
+ ## 2.3.0
40
+
41
+ ## 2.2.3
42
+
43
+ ## 2.2.2
44
+
45
+ ## 2.2.1
46
+
47
+ ## 2.2.0
48
+
49
+ ## 2.1.0
50
+
51
+ ## 2.0.1
52
+
53
+ ## 2.0.0
54
+
55
+ ## 0.24.1
56
+
57
+ ## 0.24.0
58
+
59
+ ## 0.23.0
60
+
61
+ ## 0.22.1
4
62
 
5
63
  ## 0.22.0
6
64
 
@@ -39,7 +97,6 @@
39
97
  ### Patch Changes
40
98
 
41
99
  - a7cf276: chore: upgrade NX to 21.2.3, Storybook to 9.0.9, and TypeScript to 5.8.3
42
-
43
100
  - Upgraded NX from 21.0.3 to 21.2.3 with workspace configuration updates
44
101
  - Migrated Storybook from 8.3.5 to 9.0.9 with updated configurations and automigrations
45
102
  - Upgraded TypeScript from 5.7.3 to 5.8.3 with compatibility fixes
@@ -48,7 +105,6 @@
48
105
  - Updated build configurations and dependencies to support latest versions
49
106
 
50
107
  - d31a326: refactor: sink React packages from root to individual packages
51
-
52
108
  - Removed React dependencies from root package.json and moved them to packages that actually need them
53
109
  - Fixed rsbuild-plugin configuration to match workspace patterns
54
110
  - Updated tests to handle platform-specific files
@@ -16,5 +16,4 @@ declare class ThirdPartyExtractor {
16
16
  collectPkgs(str: string): void;
17
17
  copyDts(): Promise<void>;
18
18
  }
19
-
20
19
  export { ThirdPartyExtractor };
package/dist/index.d.ts CHANGED
@@ -1,20 +1 @@
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 };
1
+ export { ThirdPartyExtractor } from './ThirdPartyExtractor';
package/dist/index.js CHANGED
@@ -6,23 +6,22 @@
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
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);
9
+ // src/ThirdPartyExtractor.ts
10
+ var _promises = require('fs/promises');
11
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
12
12
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
13
- var _resolve = require('resolve'); var _resolve2 = _interopRequireDefault(_resolve);
14
13
 
15
- // packages/third-party-dts-extractor/src/utils.ts
14
+ // src/utils.ts
15
+
16
16
 
17
- var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
18
17
  function getTypedName(name) {
19
18
  return `@types/${name.replace(/^@/, "").replace("/", "__")}`;
20
19
  }
21
- function getPackageRootDir(packageName) {
20
+ function getPackageRootDir(packageName, context = process.cwd()) {
22
21
  if (!packageName) {
23
22
  throw new Error("No package name provided.");
24
23
  }
25
- const entryFile = __require.resolve(packageName);
24
+ const entryFile = __require.resolve(packageName, { paths: [context] });
26
25
  const entryDir = _path2.default.dirname(entryFile);
27
26
  let fallbackPackageJsonPath = _path2.default.join(
28
27
  entryDir,
@@ -62,8 +61,33 @@ function getPackageRootDir(packageName) {
62
61
  `Could not find a matching package.json for "${packageName}" and no fallback was found.`
63
62
  );
64
63
  }
64
+ function resolvePackageJson(packageName, context) {
65
+ try {
66
+ return __require.resolve(`${packageName}/package.json`, {
67
+ paths: [context]
68
+ });
69
+ } catch (e) {
70
+ let currentPath = _path2.default.resolve(context);
71
+ while (true) {
72
+ const candidate = _path2.default.join(
73
+ currentPath,
74
+ "node_modules",
75
+ packageName,
76
+ "package.json"
77
+ );
78
+ if (_fs2.default.existsSync(candidate)) {
79
+ return candidate;
80
+ }
81
+ const parentPath = _path2.default.dirname(currentPath);
82
+ if (parentPath === currentPath) {
83
+ throw new Error(`Could not resolve package.json for "${packageName}".`);
84
+ }
85
+ currentPath = parentPath;
86
+ }
87
+ }
88
+ }
65
89
 
66
- // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
90
+ // src/ThirdPartyExtractor.ts
67
91
  var ignoredPkgs = ["typescript"];
68
92
  var isNodeUtils = (pkgJsonPath, importPath) => {
69
93
  return pkgJsonPath === importPath;
@@ -112,10 +136,10 @@ var ThirdPartyExtractor = class {
112
136
  if (isNodeUtils(importEntry, importPath)) {
113
137
  return;
114
138
  }
115
- const packageDir = getPackageRootDir(importPath);
139
+ const packageDir = getPackageRootDir(importPath, this.context);
116
140
  const pkgJsonPath = _path2.default.join(packageDir, "package.json");
117
141
  const dir = _path2.default.dirname(pkgJsonPath);
118
- const pkg = JSON.parse(_fsextra2.default.readFileSync(pkgJsonPath, "utf-8"));
142
+ const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgJsonPath, "utf-8"));
119
143
  const types = pkg.types || pkg.typings;
120
144
  if (dir === this.context) {
121
145
  return;
@@ -124,18 +148,14 @@ var ThirdPartyExtractor = class {
124
148
  const typesDir = _path2.default.dirname(_path2.default.resolve(dir, types));
125
149
  this.addPkgs(pkg.name, typesDir);
126
150
  return typesDir;
127
- } else if (_fsextra2.default.existsSync(_path2.default.resolve(dir, "index.d.ts"))) {
151
+ } else if (_fs.existsSync.call(void 0, _path2.default.resolve(dir, "index.d.ts"))) {
128
152
  this.addPkgs(pkg.name, dir);
129
153
  return dir;
130
154
  } else {
131
155
  const typedPkgName = getTypedName(pkg.name);
132
- const typedPkgJsonPath = _findpkg2.default.sync(
133
- _resolve2.default.sync(`${typedPkgName}/package.json`, {
134
- basedir: this.context
135
- })
136
- );
156
+ const typedPkgJsonPath = resolvePackageJson(typedPkgName, this.context);
137
157
  const typedDir = _path2.default.dirname(typedPkgJsonPath);
138
- _fsextra2.default.readFileSync(typedPkgJsonPath, "utf-8");
158
+ _fs.readFileSync.call(void 0, typedPkgJsonPath, "utf-8");
139
159
  this.addPkgs(typedPkgName, typedDir);
140
160
  return typedDir;
141
161
  }
@@ -162,33 +182,26 @@ var ThirdPartyExtractor = class {
162
182
  if (!Object.keys(this.pkgs).length) {
163
183
  return;
164
184
  }
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
- };
185
+ const ensureDir = async (dir) => _promises.mkdir.call(void 0, dir, { recursive: true });
173
186
  const copyFiles = async (srcDir, destDir) => {
174
187
  if (srcDir.startsWith(".")) {
175
188
  return;
176
189
  }
177
- const files = await _fsextra2.default.readdir(srcDir);
190
+ const files = await _promises.readdir.call(void 0, srcDir);
178
191
  await Promise.all(
179
192
  files.map(async (file) => {
180
193
  const fullPath = _path2.default.join(srcDir, file);
181
194
  if (["node_modules", "bin"].includes(file)) {
182
195
  return;
183
196
  }
184
- const stats = await _fsextra2.default.lstat(fullPath);
197
+ const stats = await _promises.lstat.call(void 0, fullPath);
185
198
  if (stats.isDirectory()) {
186
199
  const destFullPath = _path2.default.join(destDir, file);
187
200
  await ensureDir(destFullPath);
188
201
  await copyFiles(fullPath, destFullPath);
189
202
  } else {
190
203
  if (fullPath.endsWith(".d.ts") || fullPath.endsWith("package.json")) {
191
- await _fsextra2.default.copyFile(fullPath, _path2.default.join(destDir, file));
204
+ await _promises.copyFile.call(void 0, fullPath, _path2.default.join(destDir, file));
192
205
  }
193
206
  }
194
207
  })
package/dist/index.mjs CHANGED
@@ -6,23 +6,22 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
10
- import findPkg from "find-pkg";
11
- import fs2 from "fs-extra";
9
+ // src/ThirdPartyExtractor.ts
10
+ import { copyFile, lstat, mkdir, readdir } from "fs/promises";
11
+ import { existsSync, readFileSync } from "fs";
12
12
  import path2 from "path";
13
- import resolve from "resolve";
14
13
 
15
- // packages/third-party-dts-extractor/src/utils.ts
16
- import path from "node:path";
17
- import fs from "node:fs";
14
+ // src/utils.ts
15
+ import path from "path";
16
+ import fs from "fs";
18
17
  function getTypedName(name) {
19
18
  return `@types/${name.replace(/^@/, "").replace("/", "__")}`;
20
19
  }
21
- function getPackageRootDir(packageName) {
20
+ function getPackageRootDir(packageName, context = process.cwd()) {
22
21
  if (!packageName) {
23
22
  throw new Error("No package name provided.");
24
23
  }
25
- const entryFile = __require.resolve(packageName);
24
+ const entryFile = __require.resolve(packageName, { paths: [context] });
26
25
  const entryDir = path.dirname(entryFile);
27
26
  let fallbackPackageJsonPath = path.join(
28
27
  entryDir,
@@ -62,8 +61,33 @@ function getPackageRootDir(packageName) {
62
61
  `Could not find a matching package.json for "${packageName}" and no fallback was found.`
63
62
  );
64
63
  }
64
+ function resolvePackageJson(packageName, context) {
65
+ try {
66
+ return __require.resolve(`${packageName}/package.json`, {
67
+ paths: [context]
68
+ });
69
+ } catch (e) {
70
+ let currentPath = path.resolve(context);
71
+ while (true) {
72
+ const candidate = path.join(
73
+ currentPath,
74
+ "node_modules",
75
+ packageName,
76
+ "package.json"
77
+ );
78
+ if (fs.existsSync(candidate)) {
79
+ return candidate;
80
+ }
81
+ const parentPath = path.dirname(currentPath);
82
+ if (parentPath === currentPath) {
83
+ throw new Error(`Could not resolve package.json for "${packageName}".`);
84
+ }
85
+ currentPath = parentPath;
86
+ }
87
+ }
88
+ }
65
89
 
66
- // packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
90
+ // src/ThirdPartyExtractor.ts
67
91
  var ignoredPkgs = ["typescript"];
68
92
  var isNodeUtils = (pkgJsonPath, importPath) => {
69
93
  return pkgJsonPath === importPath;
@@ -112,10 +136,10 @@ var ThirdPartyExtractor = class {
112
136
  if (isNodeUtils(importEntry, importPath)) {
113
137
  return;
114
138
  }
115
- const packageDir = getPackageRootDir(importPath);
139
+ const packageDir = getPackageRootDir(importPath, this.context);
116
140
  const pkgJsonPath = path2.join(packageDir, "package.json");
117
141
  const dir = path2.dirname(pkgJsonPath);
118
- const pkg = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
142
+ const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
119
143
  const types = pkg.types || pkg.typings;
120
144
  if (dir === this.context) {
121
145
  return;
@@ -124,18 +148,14 @@ var ThirdPartyExtractor = class {
124
148
  const typesDir = path2.dirname(path2.resolve(dir, types));
125
149
  this.addPkgs(pkg.name, typesDir);
126
150
  return typesDir;
127
- } else if (fs2.existsSync(path2.resolve(dir, "index.d.ts"))) {
151
+ } else if (existsSync(path2.resolve(dir, "index.d.ts"))) {
128
152
  this.addPkgs(pkg.name, dir);
129
153
  return dir;
130
154
  } else {
131
155
  const typedPkgName = getTypedName(pkg.name);
132
- const typedPkgJsonPath = findPkg.sync(
133
- resolve.sync(`${typedPkgName}/package.json`, {
134
- basedir: this.context
135
- })
136
- );
156
+ const typedPkgJsonPath = resolvePackageJson(typedPkgName, this.context);
137
157
  const typedDir = path2.dirname(typedPkgJsonPath);
138
- fs2.readFileSync(typedPkgJsonPath, "utf-8");
158
+ readFileSync(typedPkgJsonPath, "utf-8");
139
159
  this.addPkgs(typedPkgName, typedDir);
140
160
  return typedDir;
141
161
  }
@@ -162,33 +182,26 @@ var ThirdPartyExtractor = class {
162
182
  if (!Object.keys(this.pkgs).length) {
163
183
  return;
164
184
  }
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
- };
185
+ const ensureDir = async (dir) => mkdir(dir, { recursive: true });
173
186
  const copyFiles = async (srcDir, destDir) => {
174
187
  if (srcDir.startsWith(".")) {
175
188
  return;
176
189
  }
177
- const files = await fs2.readdir(srcDir);
190
+ const files = await readdir(srcDir);
178
191
  await Promise.all(
179
192
  files.map(async (file) => {
180
193
  const fullPath = path2.join(srcDir, file);
181
194
  if (["node_modules", "bin"].includes(file)) {
182
195
  return;
183
196
  }
184
- const stats = await fs2.lstat(fullPath);
197
+ const stats = await lstat(fullPath);
185
198
  if (stats.isDirectory()) {
186
199
  const destFullPath = path2.join(destDir, file);
187
200
  await ensureDir(destFullPath);
188
201
  await copyFiles(fullPath, destFullPath);
189
202
  } else {
190
203
  if (fullPath.endsWith(".d.ts") || fullPath.endsWith("package.json")) {
191
- await fs2.copyFile(fullPath, path2.join(destDir, file));
204
+ await copyFile(fullPath, path2.join(destDir, file));
192
205
  }
193
206
  }
194
207
  })
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/third-party-dts-extractor",
3
- "version": "0.0.0-perf-devtools-20260107043700",
3
+ "version": "0.0.0-perf-website-code-usage-20260914033703",
4
4
  "files": [
5
5
  "dist/",
6
6
  "README.md"
@@ -31,12 +31,18 @@
31
31
  "types": "./dist/index.d.ts",
32
32
  "author": "hanric <hanric.zhang@gmail.com>",
33
33
  "license": "MIT",
34
- "dependencies": {
35
- "find-pkg": "2.0.0",
36
- "fs-extra": "9.1.0",
37
- "resolve": "1.22.8"
38
- },
39
34
  "devDependencies": {
40
- "@types/react": "^18.3.11"
35
+ "@rstest/core": "^0.10.6",
36
+ "@types/node": "^20.19.5",
37
+ "@types/react": "^18.3.11",
38
+ "react": "^18",
39
+ "typescript": "7.0.2",
40
+ "tsup": "7.3.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsup --config tsup.config.ts --outDir dist && tsc -p tsconfig.lib.json && cp package.json dist && cp *.md dist",
44
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\"",
45
+ "test": "pnpm exec rstest --passWithNoTests",
46
+ "pre-release": "pnpm run test && pnpm run build"
41
47
  }
42
48
  }
@@ -0,0 +1,14 @@
1
+ declare function getTypedName(name: string): string;
2
+ /**
3
+ * Locates the directory of the package.json for the given packageName.
4
+ * 1. Resolves the entry file via require.resolve().
5
+ * 2. Looks for package.json in that same directory (fallback).
6
+ * 3. Climb upward until the folder name matches localName
7
+ * (the part after a scope slash, e.g. "@scope/sdk" => "sdk").
8
+ * 4. If that folder's package.json has "name" === packageName, return that directory.
9
+ * 5. Otherwise, return the fallback directory (if it contains a package.json).
10
+ * 6. If all else fails, throw an error.
11
+ */
12
+ declare function getPackageRootDir(packageName: string | undefined, context?: string): string;
13
+ declare function resolvePackageJson(packageName: string, context: string): string;
14
+ export { getTypedName, getPackageRootDir, resolvePackageJson };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/third-party-dts-extractor",
3
- "version": "0.0.0-perf-devtools-20260107043700",
3
+ "version": "0.0.0-perf-website-code-usage-20260914033703",
4
4
  "files": [
5
5
  "dist/",
6
6
  "README.md"
@@ -31,12 +31,18 @@
31
31
  "types": "./dist/index.d.ts",
32
32
  "author": "hanric <hanric.zhang@gmail.com>",
33
33
  "license": "MIT",
34
- "dependencies": {
35
- "find-pkg": "2.0.0",
36
- "fs-extra": "9.1.0",
37
- "resolve": "1.22.8"
38
- },
39
34
  "devDependencies": {
40
- "@types/react": "^18.3.11"
35
+ "@rstest/core": "^0.10.6",
36
+ "@types/node": "^20.19.5",
37
+ "@types/react": "^18.3.11",
38
+ "react": "^18",
39
+ "typescript": "7.0.2",
40
+ "tsup": "7.3.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsup --config tsup.config.ts --outDir dist && tsc -p tsconfig.lib.json && cp package.json dist && cp *.md dist",
44
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\"",
45
+ "test": "pnpm exec rstest --passWithNoTests",
46
+ "pre-release": "pnpm run test && pnpm run build"
41
47
  }
42
48
  }