-
Notifications
You must be signed in to change notification settings - Fork 7
feat: opt-in Less v5 alpha (experimental) in the version switcher #30
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 |
|---|---|---|
|
|
@@ -34,6 +34,14 @@ async function fetchVersions() { | |
| majorMinorSet.add(majorMinor); | ||
| return true | ||
| }); | ||
| // Opt-in: surface the latest v5 alpha (npm `alpha` dist-tag). It loads the | ||
| // dev browser bundle (dist/less-browser-dev.js, window.less) — see fetchLess. | ||
| // Alphas published before that file existed will 404 and show the load tip. | ||
| // Kept out of the default so stable (`latest`) stays the landing version. | ||
| const alpha = data.tags?.alpha; | ||
| if (alpha && !publishedVersions.includes(alpha)) { | ||
| publishedVersions.unshift(alpha); | ||
|
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep the fallback stable. After Proposed fix+ const stableVersions = publishedVersions.filter(v => !v.includes("-"));
const latest = data.tags?.latest;
- const defaultVersion = (latest && publishedVersions.includes(latest))
+ const defaultVersion = (latest && stableVersions.includes(latest))
? latest
- : publishedVersions[0];
+ : stableVersions[0] ?? publishedVersions[0];🤖 Prompt for AI Agents |
||
| } | ||
| // Default to the npm `latest` dist-tag (stable, currently 4.x), never a prerelease. | ||
| const latest = data.tags?.latest; | ||
| const defaultVersion = (latest && publishedVersions.includes(latest)) | ||
|
|
@@ -49,7 +57,12 @@ async function fetchVersions() { | |
|
|
||
| function fetchLess() { | ||
| emit("upLoadingLessJS"); | ||
| const url = baseVersionUrl + activeVersion; | ||
| // v5 alpha (any prerelease) ships only a Node/CJS default entry; a browser | ||
| // <script> must load the dedicated dev bundle instead. Stable 4.x loads its | ||
| // normal UMD entry. Both define window.less with the same render API. | ||
| const url = activeVersion.includes("-") | ||
| ? `${baseVersionUrl}${activeVersion}/dist/less-browser-dev.js` | ||
| : baseVersionUrl + activeVersion; | ||
| let firstLoad = false; | ||
| const scriptDom = document.getElementById("lessScript"); | ||
| if (scriptDom) { | ||
|
|
@@ -138,11 +151,11 @@ init(); | |
| --> | ||
| <div class="version-select-click" @click.stop @click="toggle"> | ||
| <span class="active-version"> | ||
| {{ activeVersion }} | ||
| {{ activeVersion }}{{ activeVersion.includes("-") ? " (experimental)" : "" }} | ||
| </span> | ||
| <ul v-if="expanded" class="versions"> | ||
| <li v-for="(item, index) in publishedVersions" :key="index"> | ||
| <a @click="setLessVersion(item)">{{ item }}</a> | ||
| <a @click="setLessVersion(item)">{{ item }}{{ item.includes("-") ? " (experimental)" : "" }}</a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
|
|
||
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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: less/less-preview
Length of output: 10864
🏁 Script executed:
Repository: less/less-preview
Length of output: 8257
Handle first-load prerelease failures. When a saved hash restores
store.activeVersionto an alpha,fetchVersions()preserves it andinit()callsfetchLess()without an existinglessScript. The resultingfirstLoadvalue istrue, soonerrorskipsversionSelectFailandshowTip(). Set the failure state and show the load-failure tip for this path, or fall back to a stable version.🤖 Prompt for AI Agents