Module

contracts.rules_alpine_cdn

Bare jsDelivr Alpine CDN URL detection.

A barehttps://cdn.jsdelivr.net/npm/alpinejs@<version>(without an explicit/dist/cdn.min.js subpath) resolves to dist/module.cjs.js— a CommonJS module that throwsReferenceError: module is not definedin the browser. The error is silent: CORS masks it as"Script error."so nothing in the console points to the cause and every Alpine-powered component just stops working.

Chirp's ownalpine_snippetalways emits the explicit subpath; this rule guards against app developers pasting bare URLs into their own templates. Promotes the regression test intests/test_alpine.pyto a startup-time contract check.

Functions

check_alpine_cdn_urls 1 list[ContractIssue]
Flag bare jsDelivr Alpine CDN URLs in template sources. A bare ``alpinejs@`` U…
def check_alpine_cdn_urls(template_sources: dict[str, str]) -> list[ContractIssue]

Flag bare jsDelivr Alpine CDN URLs in template sources.

A barealpinejs@<version> URL (no /dist/cdn.min.js) loads the CommonJS build, which throwsReferenceError: module is not defined in the browser and is silenced by CORS. Every Alpine-powered component will quietly stop working.

Parameters
Name Type Description
template_sources dict[str, str]
Returns
list[ContractIssue]