Skip to content

Commit a206678

Browse files
dahliacodex
andcommitted
Use vocab-runtime jsonld subpath
Move the jsonld ESM shim into @fedify/vocab-runtime and expose it through the new jsonld subpath export. This avoids fragile relative imports in generated vocab sources while keeping JSR-safe packaging for the deep jsonld ESM entrypoint. Update Fedify's Linked Data signature code, the vocab code generator, snapshots, and CHANGES.md to use the shared runtime module. #639 (comment) Co-Authored-By: OpenAI Codex <codex@openai.com>
1 parent b894fbc commit a206678

13 files changed

Lines changed: 43 additions & 20 deletions

File tree

CHANGES.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ To be released.
1010

1111
### @fedify/fedify
1212

13-
- Switched Fedify's JSR-facing JSON-LD imports to jsonld's ESM entrypoint
14-
so source-based runtimes such as Deno, Cloudflare Workers, and Fresh 2's
15-
Vite SSR pipeline do not have to evaluate the package through CommonJS
16-
interop when loading Linked Data signature support. Fresh 2 development
17-
mode has been verified on Deno 2.7.7 after an upstream Deno 2.7.6 dev
18-
server regression was fixed. [[#621], [#639]]
13+
- Switched Fedify's source-based JSON-LD loading to the new
14+
`@fedify/vocab-runtime/jsonld` subpath so generated vocabulary code and
15+
Linked Data signature support no longer have to evaluate `jsonld` through
16+
a CommonJS-sensitive package root in Fresh 2, Deno, and other ESM-first
17+
runtimes. Fresh 2 development mode has been verified on Deno 2.7.7
18+
after an upstream Deno 2.7.6 dev server regression was fixed.
19+
[[#621], [#639]]
1920

2021
[#621]: https://github.com/fedify-dev/fedify/issues/621
2122
[#639]: https://github.com/fedify-dev/fedify/pull/639
@@ -28,6 +29,11 @@ To be released.
2829
`TypeError: varint.encode is not a function`. Fresh 2 no longer needs a
2930
Vite externalization workaround for Fedify. [[#621], [#639]]
3031

32+
- Added the new `@fedify/vocab-runtime/jsonld` subpath export so generated
33+
vocabulary code and other Fedify runtime code can share a JSR-safe wrapper
34+
around `jsonld`'s ESM entrypoint instead of depending on fragile relative
35+
shims or the package-root import path. [[#621], [#639]]
36+
3137
### @fedify/init
3238

3339
- Revived removed `fedify init` options. [[#632], [#638] by ChanHaeng Lee]

deno.lock

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

packages/fedify/src/sig/ld.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Activity, CryptographicKey, getTypeId, Object } from "@fedify/vocab";
22
import { type DocumentLoader, getDocumentLoader } from "@fedify/vocab-runtime";
3+
import jsonld from "@fedify/vocab-runtime/jsonld";
34
import { getLogger } from "@logtape/logtape";
45
import { SpanStatusCode, trace, type TracerProvider } from "@opentelemetry/api";
56
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
67
import { encodeHex } from "byte-encodings/hex";
7-
// @ts-ignore TS7016
8-
import jsonld from "jsonld/dist/jsonld.esm.js";
98
import metadata from "../../deno.json" with { type: "json" };
109
import { fetchKey, type KeyCache, validateCryptoKey } from "./key.ts";
1110

packages/vocab-runtime/deno.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "2.0.7",
44
"license": "MIT",
55
"exports": {
6-
".": "./src/mod.ts"
6+
".": "./src/mod.ts",
7+
"./jsonld": "./src/jsonld.ts"
78
},
89
"description": "Runtime library for @fedify/vocab",
910
"author": {
@@ -16,6 +17,7 @@
1617
"asn1js": "npm:asn1js@^3.0.6",
1718
"byte-encodings": "npm:byte-encodings@^1.0.11",
1819
"fetch-mock": "npm:fetch-mock@^12.5.4",
20+
"jsonld": "npm:jsonld@^9.0.0",
1921
"pkijs": "npm:pkijs@^3.2.5"
2022
},
2123
"exclude": [

packages/vocab-runtime/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
"require": "./dist/mod.cjs",
3636
"default": "./dist/mod.js"
3737
},
38+
"./jsonld": {
39+
"types": {
40+
"import": "./dist/jsonld.d.ts",
41+
"require": "./dist/jsonld.d.cts",
42+
"default": "./dist/jsonld.d.ts"
43+
},
44+
"import": "./dist/jsonld.js",
45+
"require": "./dist/jsonld.cjs",
46+
"default": "./dist/jsonld.js"
47+
},
3848
"./package.json": "./package.json"
3949
},
4050
"scripts": {
@@ -68,6 +78,7 @@
6878
"@opentelemetry/api": "catalog:",
6979
"asn1js": "catalog:",
7080
"byte-encodings": "catalog:",
81+
"jsonld": "^9.0.0",
7182
"pkijs": "catalog:"
7283
}
7384
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @ts-ignore TS7016
2+
import jsonld from "jsonld/dist/jsonld.esm.js";
3+
4+
export default jsonld as typeof import("jsonld");

packages/vocab-runtime/tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { defineConfig } from "tsdown";
44

55
export default [
66
defineConfig({
7-
entry: ["src/mod.ts"],
7+
entry: ["src/mod.ts", "src/jsonld.ts"],
88
dts: { compilerOptions: { isolatedDeclarations: true, declaration: true } },
99
format: ["esm", "cjs"],
1010
platform: "neutral",

packages/vocab-tools/src/__snapshots__/class.test.ts.deno.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ export const snapshot = {};
22

33
snapshot[`generateClasses() 1`] = `
44
"// deno-lint-ignore-file ban-unused-ignore prefer-const
5-
// @ts-ignore TS7016
6-
import jsonld from \\"jsonld/dist/jsonld.esm.js\\";
5+
import jsonld from \\"@fedify/vocab-runtime/jsonld\\";
76
import { getLogger } from \\"@logtape/logtape\\";
87
import { type Span, SpanStatusCode, type TracerProvider, trace }
98
from \\"@opentelemetry/api\\";

packages/vocab-tools/src/__snapshots__/class.test.ts.node.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
exports[`generateClasses() 1`] = `
22
"// deno-lint-ignore-file ban-unused-ignore prefer-const
3-
// @ts-ignore TS7016
4-
import jsonld from \\"jsonld/dist/jsonld.esm.js\\";
3+
import jsonld from \\"@fedify/vocab-runtime/jsonld\\";
54
import { getLogger } from \\"@logtape/logtape\\";
65
import { type Span, SpanStatusCode, type TracerProvider, trace }
76
from \\"@opentelemetry/api\\";

packages/vocab-tools/src/__snapshots__/class.test.ts.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
exports[`generateClasses() 1`] = `
44
"// deno-lint-ignore-file ban-unused-ignore prefer-const
5-
// @ts-ignore TS7016
6-
import jsonld from "jsonld/dist/jsonld.esm.js";
5+
import jsonld from "@fedify/vocab-runtime/jsonld";
76
import { getLogger } from "@logtape/logtape";
87
import { type Span, SpanStatusCode, type TracerProvider, trace }
98
from "@opentelemetry/api";

0 commit comments

Comments
 (0)