-
Notifications
You must be signed in to change notification settings - Fork 14
[NO-CDX] Bundle required packages #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,5 @@ require('esbuild').build({ | |
| define: { | ||
| global: 'window', | ||
| }, | ||
| external: ['@constructor-io/constructorio-id', 'crc-32'], | ||
| outfile: './lib/esm/constructorio.js', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The PR has no description, which makes it hard to understand the intent. The title says "Bundle required packages" but there's no explanation of what problem this solves (e.g., were consumers seeing missing-module errors? Was Please add a PR description explaining:
This context is important for future maintainers who encounter issues tracing back to this change. |
||
| }).catch(() => process.exit(1)); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important Issue: Removing the
externaloption causes@constructor-io/constructorio-idandcrc-32to be bundled directly intolib/esm/constructorio.js, which is the"module"entry point consumed by downstream bundlers (webpack, rollup, vite, etc.).This has two concrete risks:
Duplicate code / broken singleton semantics: If a consumer (or another package) also depends on
@constructor-io/constructorio-id, their bundler will now include two separate copies — one inside this bundle, one resolved normally. This is particularly problematic for@constructor-io/constructorio-id, which likely maintains internal singleton state (session/visitor IDs). Two copies means two independent instances, which can corrupt ID tracking.Bundle size increase: Both packages are
dependenciesinpackage.json, so consumers already receive them. Bundling them intolib/esm/means consuming applications carry the bytes twice.The
dist/esm/build (bundle-esm.js) is the appropriate place to bundle everything, as it targets standalone/CDN usage where the consumer has no package manager. Thelib/esm/build targets module-aware bundlers that should resolvedependenciesthemselves.Recommended fix: Restore the
externalarray, or if intentional, document the reasoning clearly and consider whether these packages should be moved topeerDependenciesto signal that the consumer must provide them (which would be inconsistent with the current approach). At minimum, add a comment explaining why bundling intolib/esm/is desired here.