Skip to content

[SDC-32633] Document Web SDK UMD builds - #403

Open
anthonypenna wants to merge 2 commits into
mainfrom
feature/SDC-32633-document-web-sdk-umd-builds
Open

[SDC-32633] Document Web SDK UMD builds#403
anthonypenna wants to merge 2 commits into
mainfrom
feature/SDC-32633-document-web-sdk-umd-builds

Conversation

@anthonypenna

@anthonypenna anthonypenna commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds an "Install via UMD build" section to the Web SDK installation page, covering how to load the SDK from plain <script> tags via browser globals, without a bundler — complementing the existing npm and ESM/CDN options.

Tested locally with yarn build.

Note for reviewers: the UMD build ships in 8.6.0 (SDC-31903, fix version 8.6.0-beta.1). It is not in 8.5.x — verified not cherry-picked to release/8.5 — so the /umd CDN paths in the example won't resolve until 8.6.0 is released. Please don't publish this page before the 8.6.0 release.

Closes SDC-32633

Comment thread docs/sdks/web/add-sdk.md Outdated
A classic `<script>` (unlike `<script type="module">`) does not support top-level `await`, so wrap the setup code in an async function as shown below.
:::

### Complete UMD Example

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just keep the interesting part in this section? a complete example seems superfluous and gives a lot of space to UMD in this page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — dropped the full HTML page. The section now shows only the delta over the CDN example: the two <script> tags, the globals table, and a short snippet with the async wrapper. It went from ~113 lines to ~50.

Comment thread docs/sdks/web/add-sdk.md Outdated
Comment thread docs/sdks/web/add-sdk.md Outdated
- Replace the full HTML page with just the delta over the CDN example
  (script tags, globals, async wrapper), per review feedback that a
  complete example gives UMD too much space on this page.
- Add a caution that UMD bundles can't be tree-shaken/optimized like the
  ESM build, so startup is slower, and that es-module-shims is the
  preferred fallback when import maps are the only blocker. UMD is a
  last resort.
- Use DataCaptureContext.sharedInstance in the snippet.
- Fix the CDN paths: the umd subpath resolves to build/js/umd/index.js,
  and only exports-aware resolvers understand the bare `/umd` subpath —
  raw CDN URLs need the full path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@anthonypenna

Copy link
Copy Markdown
Contributor Author

Pushed 3ed2298 addressing all review comments — replies in the threads.

One extra fix I made while in there, not from a review comment: the CDN URLs in the example were wrong. @scandit/web-datacapture-<module>/umd is only an exports subpath ("./umd" → "./build/js/umd/index.js"), and the published tarball only ships build/ and sdc-lib/ — there is no root-level umd/ directory. jsDelivr/unpkg serve raw tarball paths and do not read the exports map, so .../@scandit/web-datacapture-core@8/umd/index.js would 404. The example now uses .../build/js/umd/index.js, consistent with the ESM CDN example above. @eatsjobs please sanity-check that.

yarn build passes.

@eatsjobs

eatsjobs commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants