contracts.rules_alpine_cdn

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

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…

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.

contracts.rules_alpine_cdn

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

check_alpine_cdn_urls
function
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 Default Description
template_sources dict[str, str]

View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/rules_alpine_cdn.py:1