Skip to content

Commit 0b83567

Browse files
authored
browser support (#31)
1 parent 5979533 commit 0b83567

File tree

8 files changed

+354
-6
lines changed

8 files changed

+354
-6
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.15.0] - 2025-09-21
11+
12+
### Added
13+
14+
- **CDN Optimization** - Full support for CDN usage via unpkg and jsDelivr
15+
- Added IIFE/UMD build format that exposes `nanoStringUtils` global variable
16+
- Added `unpkg`, `jsdelivr`, and `browser` fields to package.json for optimal CDN serving
17+
- Browser users can now use the library via `<script>` tags without any build tools
18+
- Support for both classic script tags and ES modules from CDN
19+
- Created comprehensive CDN test page (`test-cdn.html`) for validation
20+
- Updated README with detailed CDN usage examples
21+
22+
### Improved
23+
24+
- **Build System** - Enhanced tsup configuration for triple output format (ESM, CJS, IIFE)
25+
- IIFE build automatically minified and tree-shaken
26+
- Source maps generated for all build formats
27+
- Global namespace properly configured as `nanoStringUtils`
28+
1029
## [0.14.0] - 2025-09-21
1130

1231
### Added

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ deno add @zheruel/nano-string-utils
7272
bun add nano-string-utils
7373
```
7474

75+
### Browser (CDN)
76+
77+
```html
78+
<!-- Latest version -->
79+
<script src="https://unpkg.com/nano-string-utils/dist/index.iife.js"></script>
80+
81+
<!-- Or specific version -->
82+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.iife.js"></script>
83+
84+
<script>
85+
// All functions available on global nanoStringUtils object
86+
const slug = nanoStringUtils.slugify("Hello World!");
87+
console.log(slug); // 'hello-world'
88+
</script>
89+
```
90+
91+
For modern browsers with ES modules:
92+
93+
```html
94+
<script type="module">
95+
import { slugify, camelCase } from 'https://unpkg.com/nano-string-utils/dist/index.js';
96+
97+
console.log(slugify("Hello World")); // 'hello-world'
98+
console.log(camelCase("hello-world")); // 'helloWorld'
99+
</script>
100+
```
101+
75102
## Quick Start
76103

77104
```javascript

docs-src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div class="header-content">
1717
<h1 class="logo">
1818
<span class="logo-text">nano-string-utils</span>
19-
<span class="version">v0.14.0</span>
19+
<span class="version">v0.15.0</span>
2020
</h1>
2121
<nav class="nav">
2222
<a href="#playground" class="nav-link active">Playground</a>

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zheruel/nano-string-utils",
3-
"version": "0.14.0",
3+
"version": "0.15.0",
44
"exports": "./src/index.ts",
55
"publish": {
66
"include": ["src/**/*.ts", "README.md", "LICENSE", "CHANGELOG.md"],

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
22
"name": "nano-string-utils",
3-
"version": "0.14.0",
3+
"version": "0.15.0",
44
"description": "Ultra-lightweight string utilities with zero dependencies",
55
"type": "module",
66
"main": "./dist/index.cjs",
77
"module": "./dist/index.js",
88
"types": "./dist/index.d.ts",
9+
"unpkg": "./dist/index.iife.js",
10+
"jsdelivr": "./dist/index.iife.js",
11+
"browser": {
12+
"./dist/index.cjs": "./dist/index.js"
13+
},
914
"bin": {
1015
"nano-string": "./bin/nano-string.js"
1116
},

0 commit comments

Comments
 (0)