Repository navigation
Remove ESM bundles and point to source directly - #739
Merged
Merged
Conversation
β Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
The main "." export's ESM entry pointed to the bundled ./dist/color.js, while ./fn and ./spaces already exported src/ directly. This left the OOP entry point as the only ESM export still resolving to a separate bundled copy of the library, with its own color-space registry distinct from anyone importing src/ β the cause of color-js/elements#192, where custom spaces registered via one instance don't appear in the other. Point the ESM import (and the "module" field) at ./src/index.js so npm consumers get a single instance. CJS continues to use the dist bundle via "require", and the dist bundles are still built for CDN/global usage. Closes #662
LeaVerou
force-pushed
the
claude/epic-brown-7mvg9r
branch
2 times, most recently
from
June 19, 2026 11:59
2a2ddc5 to
14450a1
Compare
LeaVerou
commented
Jun 19, 2026
LeaVerou
force-pushed
the
claude/epic-brown-7mvg9r
branch
from
June 19, 2026 12:25
0b14b67 to
14450a1
Compare
With the package's ESM exports pointing at src/ directly, the bundled ESM outputs (dist/color.js, dist/color-fn.js, their .min and .legacy variants) are no longer consumed by anything. Drop them from the Rollup config; only the CommonJS bundles (for require) and the global IIFE build (for classic <script> use) still need bundling. Repoint the few remaining references at src/: the website's own colors.js asset and the CDN import examples in the README and get page now use https://colorjs.io/src/index.js, matching how src modules are already documented for partial imports.
LeaVerou
force-pushed
the
claude/epic-brown-7mvg9r
branch
from
June 19, 2026 12:48
14450a1 to
33ad2dc
Compare
LeaVerou
marked this pull request as ready for review
June 19, 2026 12:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #662
This PR removes the pre-built ESM bundles from the distribution and updates all references to point directly to the source files instead.
Summary
The ESM bundles (
dist/color.jsanddist/color-fn.js) are being removed since ESM consumers can import directly from the source via the package'sexportsfield. This simplifies the build process and reduces maintenance overhead by eliminating the need to keep bundled ESM files in sync with source changes.It also fixes the dual-instance problem behind color-js/elements#192: when the main
.export resolved to a separate bundled copy, consumers importingsrc/got a differentColor(with its own color-space registry) than those importing the package root, so custom spaces registered through one didn't appear in the other.Key Changes
.ESMexportsand themodulefield to point tosrc/index.jsinstead of the bundleddist/color.js, matching how./fnand./spacesalready exportsrc/.colors.jsasset to referencesrc/index.jsdirectly.Implementation Details
exportsconfiguration.dist/color.cjs(anddist/color-fn.cjsfor./fn).<script>users continue to use the global IIFE build (dist/color.global.js), and the.legacyCommonJS/global builds are unaffected.