semaphore: export multiple other build formats#518
Conversation
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR extends the build to emit multiple module-format artifacts (cjs, es, amd, iife, system) and updates Semaphore CI (build, staging, production) to produce, publish, pull, upload, and CloudFront-invalidate those new dist artifacts alongside existing outputs. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant SemaphoreCI
participant ArtifactStore as Semaphore Artifacts
participant S3
participant CloudFront
Developer->>SemaphoreCI: push changes / trigger pipeline
SemaphoreCI->>SemaphoreCI: checkout, npm install, npm run build
SemaphoreCI->>ArtifactStore: push artifacts (`clevertap.js`, `clevertap.min.js`, `dist/*`)
Note over SemaphoreCI,ArtifactStore: deploy jobs pull artifacts
SemaphoreCI->>ArtifactStore: pull artifacts (including `dist/*`)
SemaphoreCI->>S3: aws s3 cp `clevertap.*` and `dist/*`
SemaphoreCI->>CloudFront: aws cloudfront create-invalidation for each asset path
CloudFront-->>SemaphoreCI: invalidation accepted
SemaphoreCI-->>Developer: deploy complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
rollup.config.js (1)
51-56: Inconsistent sourcemap configuration between existing and new outputs.The existing
clevertap.min.jsoutput (lines 51-56) doesn't includesourcemap: true, while all new dist outputs inheritsourcemap: truefrombaseOutput. This inconsistency may be intentional (to maintain backward compatibility), but if sourcemaps are desirable for the minified UMD build, consider adding it.Additionally, verify that the IIFE format works correctly - it requires a
namefor the global variable, which is inherited frombaseOutputas'clevertap', so this should be fine.Also applies to: 57-82
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rollup.config.js` around lines 51 - 56, The clevertap UMD minified output ("clevertap.min.js") currently lacks an explicit sourcemap setting while new dist outputs inherit sourcemap: true from baseOutput; to make behavior consistent, add sourcemap: true to the clevertap output config (the object with name: 'clevertap', file: 'clevertap.min.js', format: 'umd', plugins: [terser()]) or, if you prefer sourcemaps for all outputs, set sourcemap: true on baseOutput used by those bundles; also confirm the UMD/IIFE global name is set (name: 'clevertap') so the format: 'umd' output remains valid..semaphore/semaphore.yml (1)
18-25: Sourcemap files for dist outputs not pushed.The
baseOutputin rollup.config.js hassourcemap: true, which generates.mapfiles alongside each dist output. However, only the.jsfiles are pushed as artifacts. The staging deploy also doesn't upload these sourcemaps.If sourcemaps are needed for debugging, add artifact pushes for:
dist/clevertap_cjs.min.js.mapdist/clevertap_es.min.js.mapdist/clevertap_amd.min.js.mapdist/clevertap_iife.min.js.mapdist/clevertap_system.min.js.mapOtherwise, consider setting
sourcemap: falseinbaseOutputto avoid generating unused files.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.semaphore/semaphore.yml around lines 18 - 25, The pipeline currently pushes only the generated .js artifacts; because rollup.config.js's baseOutput has sourcemap: true, the build also emits .map files that aren't uploaded—either add artifact push entries in .semaphore/semaphore.yml for dist/clevertap_cjs.min.js.map, dist/clevertap_es.min.js.map, dist/clevertap_amd.min.js.map, dist/clevertap_iife.min.js.map and dist/clevertap_system.min.js.map (mirror the existing artifact push steps for the .js files) so sourcemaps are uploaded during staging, or change baseOutput.sourcemap in rollup.config.js to false to stop generating these files; update whichever location you choose (artifact push steps in .semaphore/semaphore.yml or baseOutput.sourcemap in rollup.config.js) accordingly..semaphore/production-deploy.yml (1)
36-41: Consider batching CloudFront invalidations.Each
aws cloudfront create-invalidationcall creates a separate invalidation request. AWS allows batching multiple paths in a single invalidation, which is more efficient and counts as one invalidation toward your monthly quota.♻️ Proposed optimization to batch invalidations
aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap_cjs.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap_es.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap_amd.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap_iife.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap_system.min.js + aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js /js/clevertap_cjs.min.js /js/clevertap_es.min.js /js/clevertap_amd.min.js /js/clevertap_iife.min.js /js/clevertap_system.min.js🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.semaphore/production-deploy.yml around lines 36 - 41, The deployment currently issues six separate aws cloudfront create-invalidation commands (e.g., "aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js" and the five other /js/clevertap_*.min.js entries); replace them with a single batched invalidation that lists all paths in one aws cloudfront create-invalidation invocation (or use a single wildcard path like /js/*) for distribution ID E1OCAMMKX0F1A1 so the invalidations count as one request and are more efficient..semaphore/staging-deploy.yml (1)
44-51: Consider batching CloudFront invalidations.Same recommendation as production-deploy.yml - batching the CloudFront invalidation calls is more efficient and reduces API calls.
♻️ Proposed optimization to batch invalidations
aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.js aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.js.map - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_cjs.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_es.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_amd.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_iife.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_system.min.js + aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_cjs.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_es.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_amd.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_iife.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_system.min.js aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/sw_webpush.min.js🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.semaphore/staging-deploy.yml around lines 44 - 51, Replace the many individual aws cloudfront create-invalidation calls for distribution E1OCAMMKX0F1A1 with a single batched invalidation that passes all paths in one request (use the --paths argument with multiple paths or provide an InvalidationBatch JSON), referencing the same /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/... entries (e.g., clevertap.js, clevertap.js.map, clevertap.min.js, clevertap_cjs.min.js, clevertap_es.min.js, clevertap_amd.min.js, clevertap_iife.min.js, clevertap_system.min.js) so you reduce API calls and keep SEMAPHORE_GIT_WORKING_BRANCH substitution intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.semaphore/production-deploy.yml:
- Around line 36-41: The deployment currently issues six separate aws cloudfront
create-invalidation commands (e.g., "aws cloudfront create-invalidation
--distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js" and the five
other /js/clevertap_*.min.js entries); replace them with a single batched
invalidation that lists all paths in one aws cloudfront create-invalidation
invocation (or use a single wildcard path like /js/*) for distribution ID
E1OCAMMKX0F1A1 so the invalidations count as one request and are more efficient.
In @.semaphore/semaphore.yml:
- Around line 18-25: The pipeline currently pushes only the generated .js
artifacts; because rollup.config.js's baseOutput has sourcemap: true, the build
also emits .map files that aren't uploaded—either add artifact push entries in
.semaphore/semaphore.yml for dist/clevertap_cjs.min.js.map,
dist/clevertap_es.min.js.map, dist/clevertap_amd.min.js.map,
dist/clevertap_iife.min.js.map and dist/clevertap_system.min.js.map (mirror the
existing artifact push steps for the .js files) so sourcemaps are uploaded
during staging, or change baseOutput.sourcemap in rollup.config.js to false to
stop generating these files; update whichever location you choose (artifact push
steps in .semaphore/semaphore.yml or baseOutput.sourcemap in rollup.config.js)
accordingly.
In @.semaphore/staging-deploy.yml:
- Around line 44-51: Replace the many individual aws cloudfront
create-invalidation calls for distribution E1OCAMMKX0F1A1 with a single batched
invalidation that passes all paths in one request (use the --paths argument with
multiple paths or provide an InvalidationBatch JSON), referencing the same
/staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/... entries (e.g., clevertap.js,
clevertap.js.map, clevertap.min.js, clevertap_cjs.min.js, clevertap_es.min.js,
clevertap_amd.min.js, clevertap_iife.min.js, clevertap_system.min.js) so you
reduce API calls and keep SEMAPHORE_GIT_WORKING_BRANCH substitution intact.
In `@rollup.config.js`:
- Around line 51-56: The clevertap UMD minified output ("clevertap.min.js")
currently lacks an explicit sourcemap setting while new dist outputs inherit
sourcemap: true from baseOutput; to make behavior consistent, add sourcemap:
true to the clevertap output config (the object with name: 'clevertap', file:
'clevertap.min.js', format: 'umd', plugins: [terser()]) or, if you prefer
sourcemaps for all outputs, set sourcemap: true on baseOutput used by those
bundles; also confirm the UMD/IIFE global name is set (name: 'clevertap') so the
format: 'umd' output remains valid.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 61353098-1c6b-4699-82f9-d4916ad82b0c
📒 Files selected for processing (4)
.semaphore/production-deploy.yml.semaphore/semaphore.yml.semaphore/staging-deploy.ymlrollup.config.js
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.semaphore/staging-deploy.yml (1)
46-51: Batch CloudFront invalidations into one request.These invalidations work, but issuing one API call with all paths is faster and reduces request overhead/rate-limit risk in CI.
Suggested refactor
- aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.js.map - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_cjs.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_es.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_amd.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_iife.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_system.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/sw_webpush.min.js - aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/sw_webpush.js + aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.js.map \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_cjs.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_es.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_amd.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_iife.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap_system.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/sw_webpush.min.js \ + /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/sw_webpush.js🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.semaphore/staging-deploy.yml around lines 46 - 51, Replace the repeated aws cloudfront create-invalidation calls with a single aws cloudfront create-invalidation invocation that passes all JS paths in one --paths argument; use the same --distribution-id E1OCAMMKX0F1A1 and interpolate SEMAPHORE_GIT_WORKING_BRANCH for each path (e.g., /staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap*.min.js expanded into the explicit list) so the pipeline issues one batched invalidation request instead of multiple calls..semaphore/semaphore.yml (1)
14-17: Usenpm ciinstead ofnpm installin CI pipelines for reproducibility.With
package-lock.jsonpresent at the repository root, line 16 should usenpm cito ensure consistent, reproducible builds across CI runs instead ofnpm install, which may resolve different versions.Suggested change
set -euo pipefail - npm install + npm ci npm run build🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.semaphore/semaphore.yml around lines 14 - 17, The CI script currently runs "npm install" which can produce non-reproducible installs; update the pipeline command in the CI script block to use "npm ci" instead of "npm install" (ensure package-lock.json is committed at repo root so "npm ci" can run), i.e., replace the "npm install" token in the semaphore pipeline step with "npm ci" and keep the rest of the step (set -euo pipefail, npm run build) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.semaphore/semaphore.yml:
- Around line 14-17: The CI script currently runs "npm install" which can
produce non-reproducible installs; update the pipeline command in the CI script
block to use "npm ci" instead of "npm install" (ensure package-lock.json is
committed at repo root so "npm ci" can run), i.e., replace the "npm install"
token in the semaphore pipeline step with "npm ci" and keep the rest of the step
(set -euo pipefail, npm run build) unchanged.
In @.semaphore/staging-deploy.yml:
- Around line 46-51: Replace the repeated aws cloudfront create-invalidation
calls with a single aws cloudfront create-invalidation invocation that passes
all JS paths in one --paths argument; use the same --distribution-id
E1OCAMMKX0F1A1 and interpolate SEMAPHORE_GIT_WORKING_BRANCH for each path (e.g.,
/staging/${SEMAPHORE_GIT_WORKING_BRANCH}/js/clevertap*.min.js expanded into the
explicit list) so the pipeline issues one batched invalidation request instead
of multiple calls.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 92ae1554-024c-49e9-92a2-33bb6e4a4818
📒 Files selected for processing (2)
.semaphore/semaphore.yml.semaphore/staging-deploy.yml
SNE-52380
Changes
add multiple output formats
Changes to Public Facing API if any
NA
How Has This Been Tested?
Tested the pipeline on staging
Checklist
Link to Deployed SDK
Use these url for testing :
https://static.wizrocket.com/staging/<CURRENT_BRANCH_NAME>/js/clevertap.min.jshttps://static.wizrocket.com/staging/<CURRENT_BRANCH_NAME>/js/sw_webpush.min.jsHow to trigger Automations
Just add a empty commit after all your changes are done in the PR with the command
git commit --allow-empty -m "[run-test] Testing Automation"This will trigger the automation suite
Summary by CodeRabbit
New Features
Chores