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
165 changes: 0 additions & 165 deletions .claude/skills/pr/SKILL.md

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.claude
node_modules
dist
demo/demo.js
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.12.3] - 2026-04-02

### Fixed
- `router.go()` no longer exposes the `state` option for routes where no state type is declared, preventing accidental state passing on untyped routes

Expand Down
12 changes: 10 additions & 2 deletions packages/esroute-lit/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"name": "@esroute/lit",
"version": "0.12.2",
"version": "0.12.3",
"description": "A small efficient client-side routing library for lit, written in TypeScript.",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
Comment on lines +5 to +13
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Compare published metadata to validate whether CJS compatibility changed.
for v in 0.12.2 0.12.3; do
  echo "=== `@esroute/lit`@$v ==="
  curl -s "https://registry.npmjs.org/@esroute/lit/$v" | jq '{
    version,
    type,
    main,
    exports
  }'
done

Repository: sv2dev/esroute

Length of output: 286


🏁 Script executed:

cat packages/esroute-lit/package.json | head -20

Repository: sv2dev/esroute

Length of output: 644


🏁 Script executed:

#!/bin/bash
# Find what version is in the current package.json
version=$(grep -oP '"version"\s*:\s*"\K[^"]+' packages/esroute-lit/package.json)
echo "Current version in repo: $version"

# Query NPM for versions around this one
npm_response=$(curl -s "https://registry.npmjs.org/@esroute/lit" | jq -r '.versions | keys | .[-5:]' 2>/dev/null)
echo "Recent versions on NPM:"
echo "$npm_response"

Repository: sv2dev/esroute

Length of output: 171


Patch release introduces breaking module-format change that should be a major version bump.

Adding "type": "module" without providing a "require" export condition breaks CommonJS consumers. Version 0.12.2 had no "type" field (treating .js files as CommonJS), while 0.12.3 now treats them as ESM-only. This violates semver for a patch release.

Either (a) release this as 1.0.0+ (breaking change), or (b) provide dual exports with corresponding CommonJS build artifacts:

"exports": {
  ".": {
    "import": "./dist/index.js",
    "require": "./dist/index.cjs"
  }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/esroute-lit/package.json` around lines 5 - 13, The patch added
"type": "module" causing a breaking change for CommonJS consumers; fix by either
releasing as a major version bump or by restoring CJS compatibility: build a
CommonJS bundle (e.g., dist/index.cjs) and adjust the package.json exports to
provide both "import" and "require" conditions and ensure "main" or "exports"
points to the CJS entry for require users; update the "types" mapping if needed
so dist/index.d.ts still matches both builds and remove or document "type":
"module" if you choose the dual-build approach.

"sideEffects": false,
"license": "MIT",
"author": "Sven Rogge <mail@sven-rogge.com>",
Expand All @@ -22,7 +30,7 @@
"typescript": "^5.4.5"
},
"dependencies": {
"esroute": "^0.12.2",
"esroute": "^0.12.3",
"lit": "^3.1.1"
}
}
2 changes: 1 addition & 1 deletion packages/esroute-lit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "esroute";
export * from "./render-routes-directive";
export * from "./render-routes-directive.js";
2 changes: 1 addition & 1 deletion packages/esroute-lit/src/render-routes-directive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRouter } from "esroute";
import { html, render } from "lit";
import { beforeEach, describe, expect, it } from "vitest";
import { renderRoutes } from "./render-routes-directive";
import { renderRoutes } from "./render-routes-directive.js";

const router = createRouter<any>({
routes: {
Expand Down
9 changes: 8 additions & 1 deletion packages/esroute/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{
"name": "esroute",
"version": "0.12.2",
"version": "0.12.3",
"description": "A small efficient framework-agnostic client-side routing library, written in TypeScript.",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"sideEffects": false,
"license": "MIT",
"author": "Sven Rogge <mail@sven-rogge.com>",
Expand Down
10 changes: 5 additions & 5 deletions packages/esroute/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./nav-opts";
export * from "./route-resolver";
export * from "./router";
export * from "./routes";
export * from "./scroll-restoration";
export * from "./nav-opts.js";
export * from "./route-resolver.js";
export * from "./router.js";
export * from "./routes.js";
export * from "./scroll-restoration.js";
2 changes: 1 addition & 1 deletion packages/esroute/src/nav-opts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { NavOpts } from "./nav-opts";
import { NavOpts } from "./nav-opts.js";

describe("NavOpts", () => {
describe("properties", () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/esroute/src/route-resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import { NavOpts } from "./nav-opts";
import { resolve } from "./route-resolver";
import { Routes } from "./routes";
import { NavOpts } from "./nav-opts.js";
import { resolve } from "./route-resolver.js";
import { Routes } from "./routes.js";

describe("Resolver", () => {
const notFound = vi.fn();
Expand Down
4 changes: 2 additions & 2 deletions packages/esroute/src/route-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NavOpts } from "./nav-opts";
import { Resolve, Routes } from "./routes";
import { NavOpts } from "./nav-opts.js";
import { Resolve, Routes } from "./routes.js";

export interface Resolved<T, S = any> {
/** The resolved value of the route. */
Expand Down
6 changes: 3 additions & 3 deletions packages/esroute/src/router.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi, type Mock } from "vitest";
import { NavOpts } from "./nav-opts";
import { Routes } from "./routes";
import { createRouter } from "./router";
import { NavOpts } from "./nav-opts.js";
import { Routes } from "./routes.js";
import { createRouter } from "./router.js";

// Define routes with proper typing to verify RoutePaths inference
// Note: "fail" route is included for testing error handling
Expand Down
8 changes: 4 additions & 4 deletions packages/esroute/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NavMeta, NavOpts, PathOrHref, StrictNavMeta } from "./nav-opts";
import { Resolved, resolve } from "./route-resolver";
import { NavMeta, NavOpts, PathOrHref, StrictNavMeta } from "./nav-opts.js";
import { Resolved, resolve } from "./route-resolver.js";
import {
Resolve,
Routes,
Expand All @@ -8,7 +8,7 @@ import {
HandlerFor,
StateOf,
NeedsState,
} from "./routes";
} from "./routes.js";

export type OnResolveListener<T, S = any> = (resolved: Resolved<T, S>) => void;
export interface Router<T = any, S = any, R extends RawRoutes = RawRoutes> {
Expand Down Expand Up @@ -97,7 +97,7 @@ export interface RouterConf<T = any, S = any, R extends RawRoutes = RawRoutes> {

export const createRouter = <T = any, S = any, R extends RawRoutes = RawRoutes>({
routes = {} as R & Routes<T, S>,
notFound = ({ go }) => go([]),
notFound = ({ go }: NavOpts<S>) => go([]),
noClick = false,
onResolve,
}: RouterConf<T, S, R> = {}): Router<T, S, R> => {
Expand Down
2 changes: 1 addition & 1 deletion packages/esroute/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NavOpts } from "./nav-opts";
import { NavOpts } from "./nav-opts.js";

export type RawRoutes = {
[k: string]: RawRoutes | ((...args: any[]) => any);
Expand Down
2 changes: 1 addition & 1 deletion packages/esroute/src/scroll-restoration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NavOpts } from "./nav-opts";
import { NavOpts } from "./nav-opts.js";

export const restoreHandling = ({
container = document.scrollingElement ?? document.body,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"target": "es2019",
"module": "esnext",
"module": "node16",
"moduleDetection": "force",
"moduleResolution": "bundler",
"moduleResolution": "node16",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
Expand Down
Loading