Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Install Dependencies
run: bun install --frozen-lockfile

- name: Build packages
run: npm run build
- name: Prepare wouter-preact (copy source files)
run: cd packages/wouter-preact && npm run prepublishOnly

- name: Run test
run: bun run test -- --run --coverage
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ jobs:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Prepare wouter-preact (copy source files)
run: cd packages/wouter-preact && npm run prepublishOnly
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_step: build
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ Wouter's motto is **"Minimalist-friendly"**.
- `wouter-preact` reuses the same source except for `react-deps.js` (Preact-specific hooks)
- Type definitions are duplicated between packages (not ideal, but works for now)

**Development:** Launch the build watcher in a separate terminal with `npm run watch`, then run tests with `npm run test` for interactive mode or `npm run test -- --run` for a single run.
**Development:** Tests run directly from source files (no build required). Run `npm run test` for interactive mode or `npm run test -- --run` for a single run. Use `npm run build` to build the distributable package before publishing.

## Acknowledgements

Expand Down
408 changes: 128 additions & 280 deletions bun.lock

Large diffs are not rendered by default.

37 changes: 13 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
"fix:p": "prettier --write \"./**/*.(js|ts){x,}\"",
"test": "vitest",
"size": "size-limit",
"build": "npm run build -ws",
"watch": "concurrently -n wouter,wouter-preact \"npm run -w packages/wouter watch\" \"npm run -w packages/wouter-preact watch\"",
"watch-bun": "concurrently -n wouter,wouter-preact \"bun run --filter wouter watch\" \"bun run --filter wouter-preact watch\"",
"lint": "eslint packages/**/*.js",
"lint-types": "vitest --typecheck"
"lint-types": "vitest --typecheck.only"
},
"author": "Alexey Taktarov <molefrog@gmail.com>",
"repository": {
Expand All @@ -31,15 +28,15 @@
},
"size-limit": [
{
"path": "packages/wouter/esm/index.js",
"path": "packages/wouter/src/index.js",
"limit": "2500 B",
"ignore": [
"react",
"use-sync-external-store"
]
},
{
"path": "packages/wouter/esm/use-browser-location.js",
"path": "packages/wouter/src/use-browser-location.js",
"limit": "1000 B",
"import": "{ useBrowserLocation }",
"ignore": [
Expand All @@ -48,31 +45,31 @@
]
},
{
"path": "packages/wouter/esm/memory-location.js",
"path": "packages/wouter/src/memory-location.js",
"limit": "1000 B",
"ignore": [
"react",
"use-sync-external-store"
]
},
{
"path": "packages/wouter/esm/use-hash-location.js",
"path": "packages/wouter/src/use-hash-location.js",
"limit": "1000 B",
"ignore": [
"react",
"use-sync-external-store"
]
},
{
"path": "packages/wouter-preact/esm/index.js",
"path": "packages/wouter-preact/src/index.js",
"limit": "2500 B",
"ignore": [
"preact",
"preact/hooks"
]
},
{
"path": "packages/wouter-preact/esm/use-browser-location.js",
"path": "packages/wouter-preact/src/use-browser-location.js",
"limit": "1000 B",
"import": "{ useBrowserLocation }",
"ignore": [
Expand All @@ -81,15 +78,15 @@
]
},
{
"path": "packages/wouter-preact/esm/use-hash-location.js",
"path": "packages/wouter-preact/src/use-hash-location.js",
"limit": "1000 B",
"ignore": [
"preact",
"preact/hooks"
]
},
{
"path": "packages/wouter-preact/esm/memory-location.js",
"path": "packages/wouter-preact/src/memory-location.js",
"limit": "1000 B",
"ignore": [
"preact",
Expand Down Expand Up @@ -135,35 +132,27 @@
},
"devDependencies": {
"@preact/preset-vite": "^2.9.0",
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.7",
"@size-limit/preset-small-lib": "^11.2.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^16.3.0",
"@types/babel__core": "^7.20.5",
"@types/bun": "^1.2.14",
"@types/react": "^18.2.0",
"@types/react-test-renderer": "^18.0.0",
"@vitejs/plugin-react": "^4.0.4",
"@vitest/coverage-v8": "^3.0.8",
"concurrently": "^8.2.2",
"@vitest/coverage-v8": "^4.0.0",
"copyfiles": "^2.4.1",
"eslint": "^7.19.0",
"eslint-plugin-react-hooks": "^4.6.2",
"happy-dom": "^17.4.7",
"happy-dom": "^20.0.10",
"husky": "^4.3.0",
"path-to-regexp": "^6.2.1",
"preact": "^10.23.2",
"preact-render-to-string": "^6.5.9",
"prettier": "^2.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.2",
"rollup": "^3.29.5",
"size-limit": "^10.0.1",
"size-limit": "^11.2.0",
"typescript": "5.2.2",
"vitest": "^3.0.8"
"vitest": "^4.0.0"
}
}
8 changes: 8 additions & 0 deletions packages/wouter-preact/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copied from wouter during prepublish (react-deps.js stays as the Preact version)
src/index.js
src/memory-location.js
src/paths.js
src/use-browser-location.js
src/use-hash-location.js
src/use-sync-external-store.js
src/use-sync-external-store.native.js
16 changes: 7 additions & 9 deletions packages/wouter-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
"useLocation"
],
"files": [
"esm",
"src",
"types/**/*.d.ts",
"types/*.d.ts"
],
"main": "esm/index.js",
"main": "src/index.js",
"exports": {
".": {
"types": "./types/index.d.ts",
"default": "./esm/index.js"
"default": "./src/index.js"
},
"./use-browser-location": {
"types": "./types/use-browser-location.d.ts",
"default": "./esm/use-browser-location.js"
"default": "./src/use-browser-location.js"
},
"./use-hash-location": {
"types": "./types/use-hash-location.d.ts",
"default": "./esm/use-hash-location.js"
"default": "./src/use-hash-location.js"
},
"./memory-location": {
"types": "./types/memory-location.d.ts",
"default": "./esm/memory-location.js"
"default": "./src/memory-location.js"
}
},
"types": "types/index.d.ts",
Expand All @@ -54,9 +54,7 @@
}
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"prepublishOnly": "npm run build && cp ../../README.md ."
"prepublishOnly": "copyfiles -f ../wouter/src/index.js ../wouter/src/memory-location.js ../wouter/src/paths.js ../wouter/src/use-browser-location.js ../wouter/src/use-hash-location.js ../wouter/src/use-sync-external-store.js ../wouter/src/use-sync-external-store.native.js src && cp ../../README.md ."
},
"author": "Alexey Taktarov <molefrog@gmail.com>",
"repository": {
Expand Down
28 changes: 0 additions & 28 deletions packages/wouter-preact/rollup.config.js

This file was deleted.

4 changes: 4 additions & 0 deletions packages/wouter-preact/setup-vitest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { expect } from "vitest";
import * as matchers from "@testing-library/jest-dom/matchers";

expect.extend(matchers);
15 changes: 13 additions & 2 deletions packages/wouter-preact/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
"compilerOptions": {
"target": "ES2022",
"moduleResolution": "node",
"module": "es2020",
"strict": true,
"jsx": "react-jsx",
"jsxImportSource": "preact",
"types": ["preact"]
}
"baseUrl": ".",
"paths": {
"wouter-preact": ["./types/index.d.ts"],
"wouter-preact/use-browser-location": ["./types/use-browser-location.d.ts"],
"wouter-preact/use-hash-location": ["./types/use-hash-location.d.ts"],
"wouter-preact/memory-location": ["./types/memory-location.d.ts"],
"wouter": ["../wouter/types/index.d.ts"]
},
"types": ["vitest/globals", "@testing-library/jest-dom", "preact"],
"skipLibCheck": true
},
"include": ["src/**/*", "test/**/*"]
}
14 changes: 14 additions & 0 deletions packages/wouter-preact/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { defineProject } from "vitest/config";
import preact from "@preact/preset-vite";
import { resolve } from "node:path";

export default defineProject({
plugins: [preact()],
resolve: {
alias: {
// wouter-preact uses its own source files (copied from wouter with react-deps -> Preact version)
"./react-deps.js": resolve(__dirname, "./src/react-deps.js"),
"wouter-preact/use-browser-location": resolve(__dirname, "./src/use-browser-location.js"),
"wouter-preact/use-hash-location": resolve(__dirname, "./src/use-hash-location.js"),
"wouter-preact/memory-location": resolve(__dirname, "./src/memory-location.js"),
"wouter-preact": resolve(__dirname, "./src/index.js"),
"wouter": resolve(__dirname, "../wouter/src/index.js"),
},
},
test: {
name: "wouter-preact",
globals: true,
environment: "happy-dom",
setupFiles: "./setup-vitest.ts",
},
});
16 changes: 7 additions & 9 deletions packages/wouter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
"useLocation"
],
"files": [
"esm",
"src",
"types/**/*.d.ts",
"types/*.d.ts"
],
"main": "esm/index.js",
"main": "src/index.js",
"exports": {
".": {
"types": "./types/index.d.ts",
"default": "./esm/index.js"
"default": "./src/index.js"
},
"./use-browser-location": {
"types": "./types/use-browser-location.d.ts",
"default": "./esm/use-browser-location.js"
"default": "./src/use-browser-location.js"
},
"./use-hash-location": {
"types": "./types/use-hash-location.d.ts",
"default": "./esm/use-hash-location.js"
"default": "./src/use-hash-location.js"
},
"./memory-location": {
"types": "./types/memory-location.d.ts",
"default": "./esm/memory-location.js"
"default": "./src/memory-location.js"
}
},
"types": "types/index.d.ts",
Expand All @@ -54,9 +54,7 @@
}
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"prepublishOnly": "npm run build && cp ../../README.md ."
"prepublishOnly": "cp ../../README.md ."
},
"author": "Alexey Taktarov <molefrog@gmail.com>",
"repository": {
Expand Down
29 changes: 0 additions & 29 deletions packages/wouter/rollup.config.js

This file was deleted.

5 changes: 4 additions & 1 deletion packages/wouter/setup-vitest.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import "@testing-library/jest-dom/vitest";
import { expect } from "vitest";
import * as matchers from "@testing-library/jest-dom/matchers";

expect.extend(matchers);
2 changes: 1 addition & 1 deletion packages/wouter/test/link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("<Link />", () => {
});

it("passes ref to <a />", () => {
const refCallback = vi.fn<[HTMLAnchorElement], void>();
const refCallback = vi.fn<(element: HTMLAnchorElement) => void>();
const { getByText } = render(
<Link href="/" ref={refCallback}>
Testing
Expand Down
Loading