Skip to content

Commit 2a2042d

Browse files
fix(utils): align package.json entrypoints with rslib output (module-federation#4439)
Co-authored-by: Pavel Tereschenko <bigslycat@protonmail.com>
1 parent e787fd3 commit 2a2042d

6 files changed

Lines changed: 28 additions & 13 deletions

File tree

.changeset/soft-spoons-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/utilities': patch
3+
---
4+
5+
fix(utilities): align published entrypoints with rslib output and add publint CI coverage.

.github/workflows/build-and-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ jobs:
8585
[ "$pkg" != "packages/chrome-devtools" ] && \
8686
[ "$pkg" != "packages/core" ] && \
8787
[ "$pkg" != "packages/modernjs" ] && \
88-
[ "$pkg" != "packages/utilities" ] && \
8988
[ "$pkg" != "packages/metro-core" ] && \
9089
[ "$pkg" != "packages/metro-plugin-rnef" ] && \
9190
[ "$pkg" != "packages/metro-plugin-rnc-cli" ]; then

.github/workflows/pkg-pr-new.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,26 @@ jobs:
6868
const config = JSON.parse(fs.readFileSync(".changeset/config.json", "utf8"));
6969
const fixed = new Set((config.fixed || []).flat());
7070
const roots = ["packages", "apps"];
71-
const results = [];
71+
const skipDirNames = new Set(["dist", "node_modules", ".git", ".nx"]);
72+
const packagePathByName = new Map();
7273
7374
function walk(dir) {
7475
if (!fs.existsSync(dir)) return;
7576
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
7677
const fullPath = path.join(dir, entry.name);
7778
if (entry.isDirectory()) {
79+
if (skipDirNames.has(entry.name)) continue;
7880
walk(fullPath);
7981
continue;
8082
}
8183
if (entry.isFile() && entry.name === "package.json") {
8284
const pkgDir = path.dirname(fullPath);
8385
const pkg = JSON.parse(fs.readFileSync(fullPath, "utf8"));
8486
if (fixed.has(pkg.name) && pkg.private !== true) {
85-
results.push(pkgDir);
87+
const existing = packagePathByName.get(pkg.name);
88+
if (!existing || pkgDir.length < existing.length) {
89+
packagePathByName.set(pkg.name, pkgDir);
90+
}
8691
}
8792
}
8893
}
@@ -92,8 +97,8 @@ jobs:
9297
walk(root);
9398
}
9499
95-
// Deduplicate and sort for stable output.
96-
const sorted = Array.from(new Set(results)).sort();
100+
// Deduplicate by package name and sort for stable output.
101+
const sorted = Array.from(packagePathByName.values()).sort();
97102
process.stdout.write(JSON.stringify(sorted));
98103
')
99104

packages/utilities/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@module-federation/utilities",
33
"version": "3.1.84",
4-
"main": "./dist/index.cjs.js",
5-
"module": "./dist/index.esm.js",
6-
"types": "./dist/index.d.ts",
4+
"main": "./dist/cjs/index.js",
5+
"module": "./dist/esm/index.mjs",
6+
"types": "./dist/types/index.d.ts",
77
"license": "MIT",
88
"publishConfig": {
99
"access": "public"
@@ -18,8 +18,9 @@
1818
"directory": "packages/utilities"
1919
},
2020
"devDependencies": {
21+
"@types/react": "^18.3.11",
2122
"react": "18.3.1",
22-
"@types/react": "^18.3.11"
23+
"rsbuild-plugin-publint": "^0.2.1"
2324
},
2425
"dependencies": {
2526
"@module-federation/sdk": "workspace:*"
@@ -42,16 +43,16 @@
4243
},
4344
"exports": {
4445
".": {
45-
"types": "./dist/index.d.ts",
46-
"import": "./dist/index.esm.js",
47-
"require": "./dist/index.cjs.js"
46+
"types": "./dist/types/index.d.ts",
47+
"import": "./dist/esm/index.mjs",
48+
"require": "./dist/cjs/index.js"
4849
},
4950
"./package.json": "./package.json"
5051
},
5152
"typesVersions": {
5253
"*": {
5354
".": [
54-
"./dist/index.d.ts"
55+
"./dist/types/index.d.ts"
5556
],
5657
"type": [
5758
"./dist/type.d.ts"

packages/utilities/rslib.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { pluginPublint } from 'rsbuild-plugin-publint';
12
import { defineConfig } from '@rslib/core';
23

34
export default defineConfig({
5+
plugins: [pluginPublint()],
46
lib: [
57
{
68
format: 'esm',

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)