Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/replace-find-pkg-with-empathic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@module-federation/managers': patch
'@module-federation/third-party-dts-extractor': patch
'@module-federation/manifest': patch
---

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`.
2 changes: 1 addition & 1 deletion packages/managers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"types": "./dist/index.d.ts",
"dependencies": {
"@module-federation/sdk": "workspace:*",
"find-pkg": "2.0.0"
"empathic": "2.0.0"
},
"devDependencies": {
"webpack": "5.104.1"
Expand Down
5 changes: 2 additions & 3 deletions packages/managers/src/PKGJsonManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'path';
// @ts-ignore this pkg miss types
import finder from 'find-pkg';
import { up as findPkgUp } from 'empathic/package';
import fs from 'fs';
import { MFModuleType, logger } from '@module-federation/sdk';

Expand All @@ -24,7 +23,7 @@ export class PKGJsonManager {
return pkg;
} catch (_err) {
try {
const pkg = finder.sync(root);
const pkg = findPkgUp({ cwd: root }) as unknown as Record<string, any>;
this._pkg = pkg;
return pkg;
} catch (err) {
Expand Down
7 changes: 4 additions & 3 deletions packages/managers/src/SharedManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-ignore this pkg miss types
import findPkg from 'find-pkg';
import { up as findPkgUp } from 'empathic/package';
import path from 'path';
import fs from 'fs';
import {
Expand Down Expand Up @@ -70,7 +69,9 @@ class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.Mod
}
}
pkgPath = pkgPath || require.resolve(depName, { paths: [this.root] });
const pkgJsonPath = findPkg.sync(pkgPath);
const pkgJsonPath = findPkgUp({
cwd: path.dirname(pkgPath),
}) as string;
return {
pkg: JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')),
path: '',
Expand Down
3 changes: 1 addition & 2 deletions packages/manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"dependencies": {
"@module-federation/sdk": "workspace:*",
"@module-federation/dts-plugin": "workspace:*",
"@module-federation/managers": "workspace:*",
"find-pkg": "2.0.0"
"@module-federation/managers": "workspace:*"
},
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/third-party-dts-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"author": "hanric <hanric.zhang@gmail.com>",
"license": "MIT",
"dependencies": {
"find-pkg": "2.0.0",
"empathic": "2.0.0",
"resolve": "1.22.8"
},
"devDependencies": {
Expand Down
14 changes: 8 additions & 6 deletions packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import findPkg from 'find-pkg';
import { up as findPkgUp } from 'empathic/package';
import { copyFile, lstat, mkdir, readdir } from 'fs/promises';
import { existsSync, readFileSync } from 'fs';
import path from 'path';
Expand Down Expand Up @@ -97,11 +97,13 @@ class ThirdPartyExtractor {
return dir;
} else {
const typedPkgName = getTypedName(pkg.name);
const typedPkgJsonPath = findPkg.sync(
resolve.sync(`${typedPkgName}/package.json`, {
basedir: this.context,
}),
) as string;
const typedPkgJsonPath = findPkgUp({
cwd: path.dirname(
resolve.sync(`${typedPkgName}/package.json`, {
basedir: this.context,
}),
),
}) as string;
const typedDir = path.dirname(typedPkgJsonPath);
readFileSync(typedPkgJsonPath, 'utf-8');
this.addPkgs(typedPkgName, typedDir);
Expand Down
7 changes: 2 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading