Skip to content

Commit 2dce32b

Browse files
committed
fix: dependency resolution
1 parent 0de3cbb commit 2dce32b

File tree

6 files changed

+106
-36
lines changed

6 files changed

+106
-36
lines changed

npm/fresco/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
"dist"
2222
],
2323
"type": "module",
24-
"main": "./dist/index.js",
25-
"types": "./dist/index.d.ts",
24+
"main": "./dist/index.mjs",
25+
"types": "./dist/index.d.mts",
2626
"exports": {
2727
".": {
28-
"import": "./dist/index.js",
29-
"types": "./dist/index.d.ts"
28+
"import": "./dist/index.mjs",
29+
"types": "./dist/index.d.mts"
3030
},
3131
"./components": {
32-
"import": "./dist/components/index.js",
33-
"types": "./dist/components/index.d.ts"
32+
"import": "./dist/components/index.mjs",
33+
"types": "./dist/components/index.d.mts"
3434
},
3535
"./composables": {
36-
"import": "./dist/composables/index.js",
37-
"types": "./dist/composables/index.d.ts"
36+
"import": "./dist/composables/index.mjs",
37+
"types": "./dist/composables/index.d.mts"
3838
}
3939
},
4040
"publishConfig": {

npm/musea-mcp-server/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
"directory": "npm/musea-mcp-server"
2020
},
2121
"bin": {
22-
"musea-mcp": "./dist/cli.js"
22+
"musea-mcp": "./dist/cli.mjs"
2323
},
2424
"files": [
2525
"dist"
2626
],
2727
"type": "module",
28-
"main": "./dist/index.js",
29-
"types": "./dist/index.d.ts",
28+
"main": "./dist/index.mjs",
29+
"types": "./dist/index.d.mts",
3030
"exports": {
3131
".": {
32-
"import": "./dist/index.js",
33-
"types": "./dist/index.d.ts"
32+
"import": "./dist/index.mjs",
33+
"types": "./dist/index.d.mts"
3434
}
3535
},
3636
"publishConfig": {
@@ -39,7 +39,7 @@
3939
"scripts": {
4040
"build": "vp pack",
4141
"dev": "vp pack --watch",
42-
"start": "node dist/cli.js",
42+
"start": "node dist/cli.mjs",
4343
"check": "vp check src vite.config.ts",
4444
"check:fix": "vp check --fix src vite.config.ts",
4545
"fmt": "vp fmt --write src vite.config.ts"

npm/musea-nuxt/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"dist"
2121
],
2222
"type": "module",
23-
"main": "./dist/index.js",
24-
"types": "./dist/index.d.ts",
23+
"main": "./dist/index.mjs",
24+
"types": "./dist/index.d.mts",
2525
"exports": {
2626
".": {
27-
"import": "./dist/index.js",
28-
"types": "./dist/index.d.ts"
27+
"import": "./dist/index.mjs",
28+
"types": "./dist/index.d.mts"
2929
}
3030
},
3131
"publishConfig": {

npm/nuxt/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
"dist"
2525
],
2626
"type": "module",
27-
"main": "./dist/index.js",
28-
"types": "./dist/index.d.ts",
27+
"main": "./dist/index.mjs",
28+
"types": "./dist/index.d.mts",
2929
"exports": {
3030
".": {
31-
"import": "./dist/index.js",
32-
"types": "./dist/index.d.ts"
31+
"import": "./dist/index.mjs",
32+
"types": "./dist/index.d.mts"
3333
}
3434
},
3535
"publishConfig": {

npm/unplugin-vize/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@
2323
"dist"
2424
],
2525
"type": "module",
26-
"main": "./dist/index.js",
27-
"types": "./dist/index.d.ts",
26+
"main": "./dist/index.mjs",
27+
"types": "./dist/index.d.mts",
2828
"exports": {
2929
".": {
30-
"types": "./dist/index.d.ts",
31-
"import": "./dist/index.js",
32-
"default": "./dist/index.js"
30+
"types": "./dist/index.d.mts",
31+
"import": "./dist/index.mjs",
32+
"default": "./dist/index.mjs"
3333
},
3434
"./esbuild": {
35-
"types": "./dist/esbuild.d.ts",
36-
"import": "./dist/esbuild.js",
37-
"default": "./dist/esbuild.js"
35+
"types": "./dist/esbuild.d.mts",
36+
"import": "./dist/esbuild.mjs",
37+
"default": "./dist/esbuild.mjs"
3838
},
3939
"./rollup": {
40-
"types": "./dist/rollup.d.ts",
41-
"import": "./dist/rollup.js",
42-
"default": "./dist/rollup.js"
40+
"types": "./dist/rollup.d.mts",
41+
"import": "./dist/rollup.mjs",
42+
"default": "./dist/rollup.mjs"
4343
},
4444
"./webpack": {
45-
"types": "./dist/webpack.d.ts",
46-
"import": "./dist/webpack.js",
47-
"default": "./dist/webpack.js"
45+
"types": "./dist/webpack.d.mts",
46+
"import": "./dist/webpack.mjs",
47+
"default": "./dist/webpack.mjs"
4848
}
4949
},
5050
"publishConfig": {

scripts/package-manifests.test.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import assert from "node:assert/strict";
2+
import fs from "node:fs";
3+
import path from "node:path";
4+
import { test } from "node:test";
5+
import { fileURLToPath } from "node:url";
6+
7+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
8+
const npmDir = path.join(root, "npm");
9+
10+
function collectStrings(value: unknown, out: string[]): void {
11+
if (typeof value === "string") {
12+
out.push(value);
13+
return;
14+
}
15+
16+
if (Array.isArray(value)) {
17+
for (const item of value) collectStrings(item, out);
18+
return;
19+
}
20+
21+
if (value != null && typeof value === "object") {
22+
for (const item of Object.values(value)) collectStrings(item, out);
23+
}
24+
}
25+
26+
function isEsmPackPackage(packageDir: string): boolean {
27+
const configPath = path.join(packageDir, "vite.config.ts");
28+
if (!fs.existsSync(configPath)) return false;
29+
30+
const config = fs.readFileSync(configPath, "utf-8");
31+
return config.includes('format: "esm"') && config.includes("pack:");
32+
}
33+
34+
test("esm packed npm manifests point at mjs and d.mts outputs", () => {
35+
const failures: string[] = [];
36+
37+
for (const entry of fs.readdirSync(npmDir, { withFileTypes: true })) {
38+
if (!entry.isDirectory()) continue;
39+
40+
const packageDir = path.join(npmDir, entry.name);
41+
if (!isEsmPackPackage(packageDir)) continue;
42+
43+
const packageJsonPath = path.join(packageDir, "package.json");
44+
if (!fs.existsSync(packageJsonPath)) continue;
45+
46+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")) as {
47+
bin?: unknown;
48+
exports?: unknown;
49+
main?: unknown;
50+
name?: string;
51+
types?: unknown;
52+
};
53+
54+
const publishedPaths: string[] = [];
55+
collectStrings(packageJson.main, publishedPaths);
56+
collectStrings(packageJson.types, publishedPaths);
57+
collectStrings(packageJson.bin, publishedPaths);
58+
collectStrings(packageJson.exports, publishedPaths);
59+
60+
for (const publishedPath of publishedPaths) {
61+
if (!publishedPath.includes("dist/")) continue;
62+
63+
if (publishedPath.endsWith(".js") || publishedPath.endsWith(".d.ts")) {
64+
failures.push(`${packageJson.name ?? entry.name}: ${publishedPath}`);
65+
}
66+
}
67+
}
68+
69+
assert.deepEqual(failures, []);
70+
});

0 commit comments

Comments
 (0)