@dreher-media/dm-js-lib
v0.3.5
Published
Centralized JavaScript library for Dreher.Media websites with CDN delivery
Downloads
1,219
Readme
@dreher-media/dm-js-lib
Centralized JavaScript library for Dreher.Media websites with CDN delivery.
Installation
npm installDevelopment
Build
npm run buildThis will compile TypeScript and create dist/dm-js-lib.min.js.
Format Code
npm run formatCheck formatting:
npm run format:checkRelease Workflow
Standard Release
npm run release:patch # 1.0.0 -> 1.0.1 (builds, versions, publishes, and pushes tags)
npm run release:minor # 1.0.0 -> 1.1.0 (builds, versions, publishes, and pushes tags)
npm run release:major # 1.0.0 -> 2.0.0 (builds, versions, publishes, and pushes tags)The release script will:
- Update the version in
package.json - Create a git commit with the version change
- Create a git tag (e.g.,
v1.2.3) - automatically done bynpm version - Build the project (via
prepublishOnlyhook) - Publish to npm
- Push commits and tags to remote
Patching an Old Version
To create a patch for an older version (e.g., patch v1.2.0 while main is at v1.5.0):
# 1. Checkout the old version tag
git checkout v1.2.0
# 2. Create a branch for the patch
git checkout -b patch-1.2.1
# 3. Make your fixes, then release
npm version patch
npm publish
git push origin patch-1.2.1 --follow-tags
# 4. Switch back to main
git checkout mainSee RELEASE_WORKFLOW.md for detailed workflow documentation.
CDN Usage
jsDelivr automatically serves from npm with full semantic versioning support:
Pinned Version (Frozen)
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/[email protected]/dist/dm-js-lib.min.js"></script>Patch-Only Auto-Update
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/[email protected]/dist/dm-js-lib.min.js"></script>Automatically updates only on patch versions (e.g., 1.2.0 → 1.2.1), never on minor or major versions.
Version Range
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/dm-js-lib@^1.2.0/dist/dm-js-lib.min.js"></script>Updates to any compatible version (patches and minor versions, but not major).
Latest (Staging)
<script src="https://cdn.jsdelivr.net/npm/@dreher-media/dm-js-lib@latest/dist/dm-js-lib.min.js"></script>Always points to the newest published version.
Versioning Strategy
- All versions follow semantic versioning (semver)
- Published versions are immutable - once published to npm, never changed
- Version ranges (
@1.2.x,@^1.2.0) automatically resolve to compatible versions @latestalways points to the newest published version- Multiple minor version lines can receive security patches independently
Project Structure
dm-js-lib/
src/
types/
global.d.ts
modules/
[module files]
index.ts
dist/
dm-js-lib.min.js
package.json
tsconfig.json
rollup.config.mjsDependencies
- rollup - Build tool
- @rollup/plugin-typescript - TypeScript support
- rollup-plugin-terser - Minification
- typescript - TypeScript compiler
- prettier - Code formatter
Publishing to npm
Before publishing, ensure you have:
- An npm account
- Access to the
@dreher-mediaorganization (or change the package name) - Logged in:
npm login
Then use the release scripts which handle building and publishing automatically.
External Dependencies (Runtime)
The library integrates with these external services (loaded separately):
- FsCC (Finsweet Cookie Consent) - Cookie consent management
- Webflow - Webflow CMS and interactions
- Plyr - Video player library
- YouTube IFrame API - YouTube player
- Vimeo Player API - Vimeo player
- Dailymotion Player Library - Dailymotion player
- Swiper - Carousel/slider library (optional, for video swipers)
License
MIT
