Skip to content

Commit 41f6e4d

Browse files
committed
fix: add index.mjs wrapper so default import works without import attributes
Previously the '.' export pointed directly at registry.json, requiring consumers to write `import x from '@framers/agentos-skills/registry.json' with { type: 'json' }` (Node 22+) or the deprecated assert syntax. Bare `import x from '@framers/agentos-skills'` failed with 'needs an import attribute of type: json'. The new index.mjs reads registry.json via fs at runtime so it works on every supported Node version without flags or attributes.
1 parent 2af96b6 commit 41f6e4d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

index.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Tiny wrapper so consumers can `import registry from '@framers/agentos-skills'`
2+
// without needing the `with { type: 'json' }` import attribute (Node 22+) or the
3+
// older `assert { type: 'json' }` (deprecated). Reads registry.json at runtime
4+
// via fs so it works on every supported Node version.
5+
import { readFileSync } from 'node:fs';
6+
import { dirname, join } from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
9+
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
const registry = JSON.parse(readFileSync(join(__dirname, 'registry.json'), 'utf-8'));
11+
12+
export default registry;

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
"type": "module",
1010
"sideEffects": false,
1111
"exports": {
12-
".": "./registry.json",
12+
".": {
13+
"import": "./index.mjs",
14+
"types": "./types.d.ts"
15+
},
1316
"./registry.json": "./registry.json",
1417
"./types": "./types.d.ts",
1518
"./package.json": "./package.json"
1619
},
1720
"files": [
21+
"index.mjs",
1822
"registry",
1923
"registry.json",
2024
"types.d.ts",

0 commit comments

Comments
 (0)