Skip to content

Add build support for ES modile#38

Merged
satnam72 merged 1 commit intorc.0.2.0from
chore/add-esm-support
Sep 8, 2025
Merged

Add build support for ES modile#38
satnam72 merged 1 commit intorc.0.2.0from
chore/add-esm-support

Conversation

@satnam72
Copy link
Owner

@satnam72 satnam72 commented Sep 8, 2025

Description

  • Added Rollup configuration to generate ES module builds and updated the package version to a release candidate.

Related Issue

  • Closes N/A

Type of Change

  • New feature

How Has This Been Tested?

Using npm run build

Checklist

  • My code follows the project’s style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional Notes

N/A.

Summary by CodeRabbit

  • New Features
    • Added ES module build outputs, enabling native ESM imports and better bundler compatibility/tree‑shaking.
  • Documentation
    • Updated CHANGELOG with 0.2.0-rc release notes highlighting ESM support.
    • Updated README version badge to 0.2.0-rc.
  • Chores
    • Bumped package version to 0.2.0-rc.
    • Updated demo page version labels to reflect 0.2.0-rc.

@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

Walkthrough

Release metadata and presentation updated from beta to rc. CHANGELOG documents ESM build support. package.json version bumped. Rollup config adds two ES module outputs (regular and minified) alongside existing UMD builds. Demo HTML and README badges updated to reflect v0.2.0-rc.

Changes

Cohort / File(s) Summary of Changes
Documentation
CHANGELOG.md, README.md
Added 0.2.0-rc entry noting ESM builds; README version badge updated from v0.2.0--beta to v0.2.0--rc.
Demo assets
demo/index.html
Replaced visible version strings from v0.2.0-beta to v0.2.0-rc.
Versioning/Packaging
package.json
Bumped "version" from "0.2.0-beta" to "0.2.0-rc".
Build configuration
rollup.config.js
Added ES module outputs: dist/allonsh.esm.js (format: es) and dist/allonsh.esm.min.js (format: es, plugins: [terser()]); existing UMD outputs unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant R as Rollup
  participant T as terser()
  participant U1 as dist/allonsh.js (UMD)
  participant U2 as dist/allonsh.min.js (UMD)
  participant E1 as dist/allonsh.esm.js (ESM)  %% New
  participant E2 as dist/allonsh.esm.min.js (ESM)  %% New

  Dev->>R: run build
  R->>U1: emit UMD (sourcemap: existing)
  R->>T: minify UMD
  T-->>U2: emit UMD min
  R->>E1: emit ESM (sourcemap: false)
  R->>T: minify ESM
  T-->>E2: emit ESM min

  note over E1,E2: New ES module outputs added in 0.2.0-rc
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump the ground—release to see!
From beta’s burrow, RC hops free.
New ESM sprouts, two shiny leaves,
Rollup hums while terser weaves.
Version carrots stacked just right—
Onward, onward, ship tonight! 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/add-esm-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
README.md (1)

19-19: Badge text OK; consider switching to a dynamic version badge.

Shields double-hyphen escape correctly renders “v0.2.0-rc”. Optional: use an npm or GitHub tag version badge to avoid manual edits each release.

demo/index.html (1)

50-50: Avoid hard-coding the displayed version.

Derive this value from package.json at build time (e.g., Rollup replace or importing package.json) to prevent drift.

CHANGELOG.md (1)

5-10: Changelog entry reads well; add compare link for consistency.

Previous releases include a “Full Changelog” link—consider adding one for 0.2.0-rc too.

rollup.config.js (2)

22-32: ESM outputs look good; enable sourcemaps for non-minified builds.

Helps debugging and keeps artifacts small only where needed.

       {
         file: 'dist/allonsh.js',
         format: 'umd',
         name: 'Allonsh',
-        sourcemap: false,
+        sourcemap: true,
       },
@@
       {
         file: 'dist/allonsh.esm.js',
         format: 'es',
-        sourcemap: false,
+        sourcemap: true,
       },

34-35: Tiny improvement: prefer browser resolution explicitly.

Not required here, but adding browser resolution guards against accidental Node-targeted sub-deps in the future.

-    plugins: [resolve(), commonjs()],
+    plugins: [resolve({ browser: true }), commonjs()],
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 1128b38 and d974eaf.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • demo/index.html (1 hunks)
  • package.json (1 hunks)
  • rollup.config.js (1 hunks)

{
"name": "allonsh",
"version": "0.2.0-beta",
"version": "0.2.0-rc",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

ESM build won’t be discoverable without entry fields; dist also isn’t published.

Currently “main” points to src and there’s no “module”/“exports”, and “dist” isn’t in “files”. Consumers may import raw source and miss your new ESM build.

Apply the following updates:

@@
-  "main": "src/Allonsh.js",
+  "main": "dist/allonsh.js",
+  "module": "dist/allonsh.esm.js",
+  "browser": "dist/allonsh.js",
+  "unpkg": "dist/allonsh.min.js",
+  "jsdelivr": "dist/allonsh.min.js",
+  "exports": {
+    ".": {
+      "import": "./dist/allonsh.esm.js",
+      "require": "./dist/allonsh.js",
+      "default": "./dist/allonsh.js"
+    }
+  },
@@
   "scripts": {
     "test": "vitest",
     "format": "prettier --write .",
     "format:check": "prettier --check .",
     "build": "rollup -c",
+    "prepublishOnly": "npm run build",
     "lint": "eslint src/",
@@
   "files": [
-    "src",
+    "dist",
+    "src",
     "README.md",
     "LICENSE",
     "docs"
   ],

Run to verify packaging entries and whitelist:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "main:" && jq -r '.main' package.json
echo "module:" && jq -r '.module' package.json
echo "exports:" && jq '.exports' package.json
echo "files:" && jq -r '.files[]' package.json
jq -r '.files[]' package.json | grep -q '^dist$' || { echo "dist missing from files"; exit 1; }
echo "If already built, confirm outputs exist:"
[ -d dist ] && ls -l dist/allonsh.js dist/allonsh.min.js dist/allonsh.esm.js dist/allonsh.esm.min.js || echo "dist not built yet; run: npm run build"

Length of output: 105


Add ESM entry points and include dist in package files

• Update package.json so “main” points to your built CJS bundle and add “module”, “browser”, “unpkg”/“jsdelivr” fields
• Add an “exports” map for import/require resolution
• Include “dist” in the “files” array and run build before publishing

--- package.json
@@
-  "main": "src/Allonsh.js",
+  "main": "dist/allonsh.js",
+  "module": "dist/allonsh.esm.js",
+  "browser": "dist/allonsh.js",
+  "unpkg": "dist/allonsh.min.js",
+  "jsdelivr": "dist/allonsh.min.js",
+  "exports": {
+    ".": {
+      "import": "./dist/allonsh.esm.js",
+      "require": "./dist/allonsh.js",
+      "default": "./dist/allonsh.js"
+    }
+  },
@@
   "scripts": {
     "test": "vitest",
     "build": "rollup -c",
+    "prepublishOnly": "npm run build",
     ...
@@
   "files": [
-    "src",
+    "dist",
+    "src",
     "README.md",
     "LICENSE",
     "docs"
   ],

Committable suggestion skipped: line range outside the PR's diff.

@satnam72 satnam72 merged commit 8b93581 into rc.0.2.0 Sep 8, 2025
3 checks passed
@satnam72 satnam72 deleted the chore/add-esm-support branch September 8, 2025 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant