Repository navigation
Conversation
Bundle Size Budgets
Repository writers, including the PR author, can accept current soft-budget breaches with a reason: Use one command per platform; several lines can share a comment. Post after this report is ready for the current head. Commands in edited comments are not accepted. Acceptance applies to each currently exceeded metric up to its recorded size. Further growth or a newly exceeded metric needs fresh acceptance. Hard-budget increases require a reviewed change to Bundle and package sizeWeb bundle sizes cover shipped runtime JavaScript. Package sizes cover the full published archive, including any source maps, declarations, and documentation it contains.
Web package files (uncompressed)These are uncompressed file sizes; they do not sum to the compressed package size above.
How sizes are measuredMeasured from the PR base SHA and PR head SHA. Web bundle rows sum shipped |
|
/accept-size web Adds an explicit shopify-checkout npm entry point while preserving existing root imports and sharing the component implementation. Increase is pretty small (167 B) |
7619d5a to
004ea88
Compare
012e7d9 to
af406b3
Compare
af406b3 to
1af0910
Compare
| "(^|/)node_modules/", | ||
| "^package\\.json$", | ||
| "^src/checkout\\.types\\.ts$", | ||
| "^src/components/shopify-checkout/checkout\\.types\\.ts$", |
There was a problem hiding this comment.
Can we make this broadly target all .types.ts files?
There was a problem hiding this comment.
Done in 803048b: the reachability rule now excludes \.types\.ts$, with a comment that type-only modules are erased at compile time, so nothing reaches them at runtime.
| "./src/components/shopify-checkout/register.ts", | ||
| "./dist/index.js", | ||
| "./dist/shopify-checkout.js", | ||
| "./dist/chunks/*.js" |
There was a problem hiding this comment.
Is it guaranteed that all chunks will contain side effects?
There was a problem hiding this comment.
Not guaranteed in general, but true today. The build emits one shared chunk, chunks/register.js, and that's where customElements.define runs (both entries import it). It has to stay flagged, or consumer bundlers can drop the import and the element never registers. The consumer bundling tests in scripts/npm-package.test.ts cover that for each import combination.
The glob errs in the safe direction: a pure chunk flagged by mistake only loses tree-shaking, while a missing flag silently breaks registration.
We're following up by making the root import side-effect free: component imports (@shopify/checkout-kit/shopify-checkout, the CDN loader) register, and the root exports the class plus ShopifyCheckout.register() for manual or custom-name registration. That moves the define into dist/shopify-checkout.js, so sideEffects can drop ./dist/chunks/*.js and the root entry.
1af0910 to
b2832d8
Compare
4266b84 to
803048b
Compare
- The component entry's declarations now load the root declarations, so
`import "@shopify/checkout-kit/shopify-checkout"` alone types
document.createElement("shopify-checkout") as ShopifyCheckout. The
TypeScript consumer test no longer casts and covers both import styles.
- Exclude every `.types.ts` module from the reachability rule rather than
only checkout.types.ts (review feedback).
Follow the common web component package pattern (Shoelace/Web Awesome, Material Web, Spectrum): component imports register, and the package root only exports classes, events, and types. - `import "@shopify/checkout-kit"` no longer registers <shopify-checkout>. This is a breaking change for consumers relying on the root import to register; the README calls it out. - Add `ShopifyCheckout.register(name?, registry?)`. The default name registers the class itself; each custom name gets its own subclass, since a registry accepts a constructor only once. Registering a name the class already owns returns that class; a name owned by another element throws. - The component entry registers through `register()` and leaves an existing <shopify-checkout> in place, so loading Checkout Kit twice (bundle plus CDN loader) doesn't fail. - `sideEffects` now lists only the component entry. The shared chunk is pure and is renamed from chunks/register.js to chunks/shopify-checkout.js. - Keep the custom elements manifest's tag-to-class definition: the analyzer can't follow `register()`, so a manifest plugin recreates it from the class's `@tagname`. - dependency-cruiser treats component entries as entry points. - Package tests cover every import combination, including custom names and an existing <shopify-checkout> on the page.
f0ea1f1 to
3d2f45d
Compare
What changes are you making?
Organize Checkout Kit Web by component, register components through their own entry points, and make the package root side-effect free. This follows the common web component package pattern (Shoelace/Web Awesome, Material Web, Spectrum): component imports register, and the root exports classes, events, and types.
Consumer impact (breaking):
import '@shopify/checkout-kit'no longer registers<shopify-checkout>. Register it in one of two ways:All root exports remain available. Without either registration,
<shopify-checkout>elements stay unregistered and checkout won't open, so this needs a release note. The package is on4.0.0-alpha, and the README calls it out.Reviewing: the last commit, "Make the root import side-effect free and add ShopifyCheckout.register()", contains the registration change on top of the previously approved version.
src/components/shopify-checkout/.shopify-checkout.tscontains the implementation;register.tshandles registration. Use direct file imports without component barrel files.chunks/shopify-checkout.js) and the root are pure, sosideEffectslists only the component entry. This also answers whether every chunk has side effects: none do now.ShopifyCheckout.register(name?, registry?):register()and leaves an existing<shopify-checkout>in place, so loading Checkout Kit twice (for example a bundle plus the CDN loader) doesn't fail.register(), so a manifest plugin recreates it from the class's@tagname.dist/shopify-checkout.d.tsloads the root declarations, soimport '@shopify/checkout-kit/shopify-checkout'alone typesdocument.createElement('shopify-checkout')asShopifyCheckout(building on Ship custom element tag-name typing in the published declarations #958)..types.tsmodule from the dependency-cruiser reachability rule, not onlycheckout.types.ts.This builds on #958 (published tag-name typing); #918 adds separate CDN output and on-demand loading.
How to test
Validated with 337 unit tests, 16 Chromium tests, 9 built-package tests, lint/typechecks, publint, the sample build, and the packed-file snapshot comparison. The 22 changed-file filter tests also passed. Consumer bundling tests cover every import combination:
register();<shopify-checkout>on the page.They also verify that the component entry doesn't import the package root, and type-check strict TypeScript consumers without casts for both import styles. Unit tests cover
register()directly.