Skip to content

Commit c611249

Browse files
committed
Make @fedify/uri-template default reporter a no-op
The package advertises zero runtime dependencies (in README.md, CHANGES.md, and the empty `dependencies`/`imports` fields of *package.json* and *deno.json*), but Template imported `@logtape/logtape` to back the default reporter. That contradicted the claim and caused tsdown to bundle the entire logger into *dist/*. Drop the import and let the default reporter be a no-op. The default `strict: true` still throws after the reporter runs, so error visibility is preserved on the common path. Callers that opt into non-strict mode can pass their own `report` callback (for example, one backed by their application's logger) to observe diagnostics. Assisted-by: Claude Code:claude-opus-4-7
1 parent 04be48b commit c611249

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

packages/uri-template/src/template/template.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getLogger } from "@logtape/logtape";
21
import type {
32
ExpandContext,
43
Reporter,
@@ -28,11 +27,11 @@ export default class Template {
2827
public readonly uriTemplate: string,
2928
/**
3029
* Options for parsing the template. By default, `strict` is `true` and
31-
* `report` logs errors using the default logger. If `strict` is `true`, the
32-
* first error encountered while parsing or expanding will be automatically
33-
* thrown after being reported. If `strict` is `false`, errors will be
34-
* reported but none will be thrown unless the `report` function itself
35-
* throws. The rest of the part remains as literal text.
30+
* `report` is a no-op. If `strict` is `true`, the first error encountered
31+
* while parsing or expanding will be automatically thrown after being
32+
* reported. If `strict` is `false`, errors will be reported but none will
33+
* be thrown unless the `report` function itself throws. The rest of the
34+
* part remains as literal text.
3635
*/
3736
readonly options: Partial<TemplateOptions> = {},
3837
) {
@@ -75,9 +74,7 @@ export default class Template {
7574
toString = (): string => this.uriTemplate;
7675
}
7776

78-
const logger = getLogger(["fedify", "uri-template", "template"]);
79-
80-
const defaultReporter: Reporter = (error: Error) => logger.error(error);
77+
const defaultReporter: Reporter = () => void 0;
8178

8279
const fillOptions = (
8380
{ strict, report }: Partial<TemplateOptions>,

packages/uri-template/src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ export interface TemplateOptions {
7878
strict: boolean;
7979
/**
8080
* A function that will be called with any errors encountered while parsing
81-
* or expanding. By default, errors are logged using the default logger.
82-
* In strict mode, they are still thrown after this reporter runs.
81+
* or expanding. Defaults to a no-op; pass a callback (for example, one
82+
* backed by your application's logger) to observe diagnostics. In strict
83+
* mode, errors are still thrown after this reporter runs.
8384
* @param error The error that was encountered while parsing or expanding the
8485
* template.
8586
*/

0 commit comments

Comments
 (0)