Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [0.2.0-rc] - 2025-09-07

### Added

- Added support for ESM builds to generate ES modules

## [0.2.0-beta] - 2025-08-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ media="(prefers-color-scheme: light)"

Lightweight, dependency-free drag-and-drop with precise native target detection and easy customization.

![Version Badge](https://img.shields.io/badge/Current_Version-v0.2.0--beta-blue.svg)
![Version Badge](https://img.shields.io/badge/Current_Version-v0.2.0--rc-blue.svg)

## Features

Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h2 class="demo-header__title">
Allonsh.js
<span class="demo-header__demoText"> Demo </span>

<span class="demo-allonsh__currentVersion"> v0.2.0-beta </span>
<span class="demo-allonsh__currentVersion"> v0.2.0-rc </span>
</h2>
</div>
<div class="github-links">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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.

"description": "Lightweight, dependency-free drag-and-drop with precise native target detection and easy customization.",
"main": "src/Allonsh.js",
"directories": {
Expand Down
11 changes: 11 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export default [
plugins: [terser()],
sourcemap: false,
},
{
file: 'dist/allonsh.esm.js',
format: 'es',
sourcemap: false,
},
{
file: 'dist/allonsh.esm.min.js',
format: 'es',
plugins: [terser()],
sourcemap: false,
},
],
plugins: [resolve(), commonjs()],
},
Expand Down