Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wide-colts-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stinobe/mattr": minor
---

Moved from `yaml` to `js-yaml` to reduce package size
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@
"node": ">=18"
},
"dependencies": {
"yaml": "^2.8.4"
"js-yaml": "^4.1.1"
},
"devDependencies": {
"@changesets/cli": "^2.31.0",
"@eslint/js": "^10.0.1",
"@eslint/markdown": "^8.0.1",
"@types/js-yaml": "^4.0.9",
"@types/node": "^25.6.2",
"@vitest/coverage-v8": "^4.1.6",
"eslint": "^10.3.0",
Expand Down
47 changes: 23 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/frontmatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse as parseYaml } from "yaml";
import { load as parseYaml } from "js-yaml";
import { MattrParseError } from "@lib/errors";
import { EMPTY_OBJECT, FRONTMATTER_DELIMITTER } from "@lib/constants";
import type { MattrAllowedTypes, MattrData } from "./types";
Expand Down
6 changes: 3 additions & 3 deletions tests/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("default usage", () => {
});

it("returns empty object when `parseYaml` returns null", async () => {
vi.doMock("yaml", () => ({ parse: vi.fn(() => null) }));
vi.doMock("js-yaml", () => ({ load: vi.fn(() => null) }));
const { parseFrontmatter } = await import("@lib/frontmatter");
const parsed = parseFrontmatter(markdown);
expect(parsed).toEqual({
Expand All @@ -55,8 +55,8 @@ describe("error handeling", () => {
});

it("should throw an error when Yaml is invalid", async () => {
vi.doMock("yaml", () => ({
parse: vi.fn(() => {
vi.doMock("js-yaml", () => ({
load: vi.fn(() => {
throw new Error("Failde from Yaml");
}),
}));
Expand Down