feat: Improve package format publishing and release verification for issue #51#52
Open
anyelopetit wants to merge 4 commits into
Open
feat: Improve package format publishing and release verification for issue #51#52anyelopetit wants to merge 4 commits into
anyelopetit wants to merge 4 commits into
Conversation
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.
Summary
The package format was fixed by separating ESM and CommonJS outputs, rewriting generated internal imports/requires to explicit file extensions, preserving the existing UMD CDN artifact, adding an explicit UMD artifact name, and adding packed-package smoke tests to CI.
The root package entry remains the browser/bundler pixel entry. The
@hellotext/hellotext/vanillaentry is the Node/SSR-safe entry.Resolves #51
Decisions From Issue
./hellotext.js,./core/index.js, and./api/index.js.require()calls resolve CJS files.require('./hellotext')could resolve the adjacent.jsESM file first. Generated CJS now uses explicit.cjspaths.lib/esmandlib/cjsinstead of a largerdist/esmanddist/cjsmove. This keeps the existingdist/hellotext.jsUMD path stable../vanillaas the Node/SSR/test-safe entry.exportsmap../vanilla, CSS, and./package.jsonexports now point to precise ESM/CJS/browser/type paths.defaultexport condition pointing at UMD.default: ./dist/hellotext.jsfor compatibility with older bundlers and consumers. Removing it would be riskier than documenting and preserving it.enginesand Babel targets.src.srcmay support debugging or undocumented consumer workflows. Removing it is not required to fix package resolution and could break current users.sideEffectsnow includes CSS, root side-effectful entries, and the UMD bundle. CSS import behavior remains documented.index.d.tsis preserved for root and./vanilla. We did not redesign declarations, but the smoke test now verifies the exported package paths that rely on them.release:checkandsmoke:package;prepublishOnlynow runs the full release check.dist/hellotext.umd.jsas the explicit UMD artifact while preservingdist/hellotext.jsas the stable CDN/GTM/script-tag path. Package metadata still points todist/hellotext.jsto avoid breaking existing integrations.Package Shape Decision
Chosen output shape:
Reasons:
.jsand.cjssibling ambiguity."type": "module"..cjsfiles.typebehavior unchanged for compatibility.Entrypoint Decision
The root entry remains browser-facing:
It starts Stimulus controllers and assigns
window.Hellotext. This is intentional and matches the public pixel behavior.The vanilla entry is the Node/SSR-safe entry:
It imports the Hellotext class without starting Stimulus or touching
windowat import time.Compatibility Decisions
I intentionally preserved:
dist/hellotext.jsfor CDN/script-tag users.dist/hellotext.umd.jsas the explicit UMD artifact name.browserandunpkgfields pointing todist/hellotext.js.defaultexport condition pointing todist/hellotext.js../styles/*export in addition to the documented./styles/index.csspath.srcin published package contents for compatibility, while treating internal deep imports as unsupported public API.I intentionally did not:
srcfrom the package.Release Verification Decision
I added a packed-package smoke test because the previous CI only tested source files. The new release check validates the artifact users actually install.
The smoke test verifies:
import '@hellotext/hellotext/vanilla'require('@hellotext/hellotext/vanilla')require('@hellotext/hellotext/package.json')@hellotext/hellotext/styles/index.cssunpkgpathdist/hellotext.umd.jsexists and matches the legacydist/hellotext.jsaliasThe root package entry is intentionally browser-facing and touches browser globals, so the smoke test loads it under a minimal DOM stub rather than bare Node. It asserts the root entry imports and attaches window.Hellotext for both ESM and CJS, while still treating browser/bundler usage (via webpack) as the primary supported path.
Deep Import Decision
Deep imports are not considered public API. Supported public entrypoints are:
@hellotext/hellotext@hellotext/hellotext/vanilla@hellotext/hellotext/styles/index.css@hellotext/hellotext/package.jsonWe are still publishing
srcand generatedlibfiles for compatibility and debugging in this release, but consumers should not rely on internal paths such as@hellotext/hellotext/src/...or@hellotext/hellotext/lib/.... If real consumer needs appear, the public API should be expanded intentionally through documented exports rather than by supporting arbitrary internals.Follow-Up Candidates
These are intentionally left for future, lower-risk changes:
libanddist/hellotext.js.dist/hellotext.jsshould remain forever or become a documented legacy alias.srcshould remain in the published package.Note
Medium Risk
Changes how consumers resolve the package (exports and dual builds); risk is mitigated by preserving UMD/CDN paths and packed-artifact smoke tests, but wrong resolution could still break integrators until they upgrade.
Overview
Fixes npm package resolution for ESM and CommonJS by splitting outputs into
lib/esmandlib/cjs, with generated imports using explicit.js/.cjspaths so Node and bundlers resolve the right files. Public entrypoints stay documented: root@hellotext/hellotext(browser pixel +window.Hellotext),@hellotext/hellotext/vanilla(Node/SSR/tests), and@hellotext/hellotext/styles/index.css;exports,sideEffects, andengines(Node ≥20) are tightened accordingly.CDN/script-tag compatibility is preserved:
dist/hellotext.jsremains the metadata path;dist/hellotext.umd.jsis added as the named UMD artifact and kept identical to the legacy file. Release safety: CI runsnpm run release:check(tests, build, typecheck, packed-tarball smoke tests) instead of tests alone;prepublishOnlyuses the same gate. README and newdocs/packaging.mdexplain the layout and compatibility choices.Reviewed by Cursor Bugbot for commit c09fcf9. Bugbot is set up for automated code reviews on this repo. Configure here.