Inline cozy-sun-bear into heliotrope and switch pack to local source#3992
Draft
Copilot wants to merge 2 commits into
Draft
Inline cozy-sun-bear into heliotrope and switch pack to local source#3992Copilot wants to merge 2 commits into
cozy-sun-bear into heliotrope and switch pack to local source#3992Copilot wants to merge 2 commits into
Conversation
Copilot
AI
changed the title
[WIP] Refactor to inline cozy-sun-bear source into heliotrope
Inline May 31, 2026
cozy-sun-bear into heliotrope and switch pack to local source
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.
This PR moves the primary
cozy-sun-bearimplementation from a git URL dependency into heliotrope’s source tree so heliotrope builds and owns it directly. The change is scoped as a refactor: EPUB pack wiring is preserved,cozy-sun-bear-tooremains untouched.Source vendoring (new local module)
app/javascript/cozy-sun-bear/with upstream JS source undersrc/**and styles underscss/**.app/javascript/cozy-sun-bear/package.jsonwith a minimal version shim forimport { version } from '../package.json'.Pack entrypoint migration to local code
app/javascript/packs/cozy-sun-bear/cozy-sun-bear.jsto import from local source.app/javascript/packs/cozy-sun-bear/cozy-sun-bear.cssto import local SCSS instead of prebuilt dist CSS.Dependency ownership shift to heliotrope
cozy-sun-bearfrom rootpackage.json.cozy-sun-bear-toounchanged.ajv,epubjs(cozy-sun-bear-2026),event-emitter,jszip,lodash,mustache,path-webpack.sass,sass-loader).Webpack compatibility updates
resolve.alias.path = 'path-webpack'inconfig/webpack/environment.js..scssalongside.css.Original prompt
Goal
Move the JavaScript source of
mlibrary/cozy-sun-bear(currently consumed as a git-URL npm dependency) directly into heliotrope's own source tree, so heliotrope owns and builds it without needing the external repo. This is a pure refactor — no behaviour change, no new features. The EPUB reader must continue to work identically after this change.Background
package.jsoncurrently has:This PR only inlines the primary
cozy-sun-bear(master branch). Leavecozy-sun-bear-tooand its pack (app/javascript/packs/cozy-sun-bear-too/) completely untouched for now.What to do
1. Copy the cozy-sun-bear source into heliotrope
Fetch all files from
mlibrary/cozy-sun-bear(master branch) and place them underapp/javascript/cozy-sun-bear/in heliotrope, preserving the directory structure:src/**→app/javascript/cozy-sun-bear/src/**scss/**→app/javascript/cozy-sun-bear/scss/**The files to copy (fetch each from
https://github.com/mlibrary/cozy-sun-bear/blob/master/...):src/ root:
src/cozy.jssrc/epubjs.jssrc/readium.jssrc/screenfull.jssrc/config/, src/control/, src/core/, src/dom/, src/epubjs/, src/geometry/, src/reader/, src/utils/ — fetch the directory listings from the GitHub API and copy all
.jsfiles found within each, preserving subdirectory structure.scss/:
scss/cozy.scssscss/_loader.scssscss/_modals.scssscss/_navigator.scssscss/_open-iconic.scss2. Fix the
package.jsonimport insrc/cozy.jsThe cozy-sun-bear
src/cozy.jsdoes:After copying,
../package.jsonwould resolve to heliotrope's rootpackage.json, which is wrong. Fix this by creating a minimalapp/javascript/cozy-sun-bear/package.json:{ "version": "1.0.0" }This satisfies the named import without touching heliotrope's real package.json.
3. Update the cozy-sun-bear pack entry point
app/javascript/packs/cozy-sun-bear/cozy-sun-bear.jscurrently:Change to import from the local source. The CSS should come from the scss source, not a pre-compiled dist file:
app/javascript/packs/cozy-sun-bear/cozy-sun-bear.csscurrently:Change to import from the local scss source:
4. Update
package.jsondependenciesIn heliotrope's
package.json:"cozy-sun-bear"git dependency (the one pointing at master — do not removecozy-sun-bear-too)package.jsonlists (since heliotrope's webpack will now be building this code directly):Note:
core-jsis already present in heliotrope'spackage.json, so don't duplicate it.5. Webpack alias for
pathThe cozy-sun-bear source uses
import path from "path-webpack"via a webpackresolve.alias. Check heliotrope's webpack config (inconfig/webpack/) — if there is no existing alias forpath → path-webpack, add one. Look for anenvironment.jsor equivalent shakapacker config file inconfig/webpack/and add:6. Do NOT change
app/javascript/packs/cozy-sun-bear-too/— leave entirely alone"cozy-sun-bear-too"entry inpackage.json— leave aloneSuccess criteria
yarn build(or the equivalent shakapacker compile command) completes without errorscozy-sun-bear-toopack is untouchedwindow.cozyAPI surface)The following is the prior conversation context from the user's chat exploration (may be truncated):
User: I would like to consider how to unify the way mlibrary/heliotrope implements its ebook reader.
Some background:
mlibrary/cozy-sun-bear was originally written to use mlibrary/epub.js. Right now it uses the "cozy-sun-bear-2026" branch. Overall this is fairly stock epub.js, where the book is displayed in an iframe.
A few years later, online PDF reading was desired. The main goal was to have the interface (menus, buttons and "theme" colors) be largely the same between EPUB and PDF formats.
PDF.js was chosen...
This pull request was created from Copilot chat.