Skip to content

Conversation

@Rajesh-Royal
Copy link
Owner

Summary

Adds multi-format build outputs (ESM index.mjs, CJS index.js, and global/IIFE index.global.js), enabling direct browser usage via both <script type="module"> and classic <script> tags. Exposes getCurrentBrowserFingerPrint as a window global when loaded via the global build. Updates export map, adds tsup bundling, updates README with new CDN examples, and adds a changelog entry. Resolves inability to import the library from a CDN previously reported (window.getCurrentBrowserFingerPrint is not a function and missing named export errors).

Type of change

  • New feature (multi-format bundles / global exposure)
  • Docs update (README + changelog)
  • Chore / Maintenance (build pipeline/tooling)
  • Bug fix
  • Breaking change

Checklist

  • Code builds locally (npm run build)
  • Linting/format (N/A – project has no configured linter; manual review performed)
  • Updated documentation (README/changelog updated)
  • Added tests or explanation why not (No existing test infra; deterministic functions unchanged aside from packaging)
  • Version bump NOT included (NOTE: version already bumped to 2.2.0 as part of this branch to publish multi-format build)

How to test

  1. Install deps: npm install
  2. Build: npm run build
  3. Confirm outputs exist: lib/index.mjs, lib/index.js, lib/index.global.js, lib/index.d.ts
  4. Node CJS: node -e "const { getCurrentBrowserFingerPrint } = require('./lib'); console.log(typeof getCurrentBrowserFingerPrint);" should print function.
  5. Node ESM: node --input-type=module -e "import { getCurrentBrowserFingerPrint } from './lib/index.mjs'; console.log(typeof getCurrentBrowserFingerPrint);" should print function.
  6. Browser (module):
<script type="module">
  import { getCurrentBrowserFingerPrint } from 'https://cdn.jsdelivr.net/npm/@rajesh896/broprint.js@2.2.0/lib/index.mjs';
  getCurrentBrowserFingerPrint().then(console.log);
</script>
  1. Browser (global):
<script> getCurrentBrowserFingerPrint().then(console.log); </script>">
<script src="https://cdn.jsdelivr.net/npm/@rajesh896/broprint.js@2.2.0/lib/index.global.js"></script>
<script>
  getCurrentBrowserFingerPrint().then(console.log);
</script>

Screenshots / Logs

N/A – library build / API unchanged; packaging only.

Related issues

Fixes: CDN usage errors (unreported issue numbers) regarding missing named export and undefined global.

Additional context

  • Introduced tsup (devDependencies) for concise multi-target bundling.
  • Export map now aligns Node (CJS) and modern bundlers (ESM).
  • Added global assignment guard (if (typeof window !== 'undefined' ...)).
  • README cleaned: removed duplicate install section & outdated crypto-js note.

#7 #16

Rajesh-Royal and others added 11 commits June 21, 2022 09:01
- Updated package.json to include module and exports fields for better compatibility with ESM and CommonJS.
- Added build scripts for generating type declarations and bundling the library in multiple formats (esm, cjs, iife).
- Introduced tsup as a development dependency for efficient bundling.
- Modified src/index.ts to expose getCurrentBrowserFingerPrint as a global function for UMD/IIFE builds, ensuring compatibility with classic script usage.
@Rajesh-Royal Rajesh-Royal added the enhancement New feature or request label Aug 11, 2025
@netlify
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for broprintjs canceled.

Name Link
🔨 Latest commit 36b779a
🔍 Latest deploy log https://app.netlify.com/projects/broprintjs/deploys/68998a1d0a6c490008a702de

@Rajesh-Royal Rajesh-Royal merged commit b659d5b into master Aug 11, 2025
2 checks passed
This was linked to issues Aug 11, 2025
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update it CDN?

3 participants