singlepage-router 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +9 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -15,12 +15,19 @@ A micro client-side router with a clean TypeScript rewrite. Full `History` and `
15
15
  `singlepage-router` is a TypeScript rewrite of the classic [`page`](https://www.npmjs.com/package/page) package by [@visionmedia](https://github.com/visionmedia). The routing behaviour and API are intentionally kept familiar, but the internals have been modernised throughout:
16
16
 
17
17
  - **Written in TypeScript** — full type safety out of the box. No need for a separate `@types/` package. All classes, options, and callbacks are fully typed.
18
- - **Modern dual ESM/CJS build** — ships both `import` and `require` formats with a proper `exports` map. The original `page` predates the ESM ecosystem and relies on a single UMD/CommonJS bundle.
18
+ - **Proper dual ESM/CJS build with an `exports` map** ships both
19
+ `import` and `require` formats using a modern `package.json` `exports`
20
+ field with conditional resolution. The original `page` uses the legacy
21
+ `"module"` field pointing to a single `.mjs` file with no `exports`
22
+ map, no named exports, and no CJS/ESM conditional resolution support.
19
23
  - **Class-based internals** — `PageInstance`, `Context`, and `Route` are proper ES classes, replacing the original's prototype chain manipulation and constructor functions.
20
24
  - **No legacy code** — all `var` declarations, bitwise `~indexOf` tricks, IE-era guards, and the HTML5-History-API polyfill support have been removed. Targets modern browsers only.
21
25
  - **Updated `path-to-regexp`** — uses v6 versus the original's pinned v1.2.x, bringing improved pattern support and security fixes.
22
26
  - **`sideEffects: false`** — explicitly marked for bundler tree-shaking, so unused exports are dropped cleanly.
23
- - **Named exports** — alongside the default export, `Context`, `Route`, `PageInstance`, `createPage`, and all types are individually importable, which the original does not support cleanly.
27
+ - **Proper named ES module exports** — `Context`, `Route`, `PageInstance`,
28
+ `createPage`, and all TypeScript types are individually importable as
29
+ true ESM named exports, enabling tree-shaking and typed auto-imports
30
+ in any modern editor.
24
31
 
25
32
  The public API — `page('/path', handler)`, `page()`, `page.show()`, `page.back()`, `page.exit()` etc. — works the same way as `page`, so migration is straightforward.
26
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "singlepage-router",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Micro client-side router with History API, hashbang, and middleware support. TypeScript rewrite of page.js with full type safety and dual ESM/CJS output.",
5
5
  "author": "openchubura",
6
6
  "license": "MIT",