npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ab-test-sdk/codemod

v0.1.1

Published

A/B Test SDK codemod CLI — inject data-ab ids into Vue 3 source

Downloads

92

Readme

@ab-test-sdk/codemod

@ab-test-sdk/sdk 的伴隨 CLI —— 掃描 Vue 3 .vue,為可定位的元素自動注入穩定的 data-ab id。

id 一次性寫進 source code、跨 build 不變,是整套穩定身份系統的基礎,讓實驗定位不因網站改版而失效。

完整架構與設計說明見 專案 README

安裝

pnpm add -D @ab-test-sdk/codemod

使用

pnpm exec ab-codemod inject src
  • 參數為要掃描的資料夾(省略則為當前目錄);建議指向 src,避免掃進 node_modules
  • 已有 data-ab 的元素會跳過,可安全重複執行(只補新元素)。

效果

注入前後(只新增屬性,保留你原始的程式碼格式):

- <button class="hero__cta">Shop now</button>
+ <button class="hero__cta" data-ab="beba2d0c">Shop now</button>

這個 data-ab 寫進原始碼後就固定下來,之後 SDK 便以它定位元素來套用實驗與追蹤。

服務範圍

只對這些白名單標籤注入 data-abbuttonainputselecttextareaformh1h6imgvideoaudiopspanli

限制

  • 跳過:自訂元件(大寫開頭 / 含 -)、Vue 結構標籤(templateslot…)、含 v-html 的元素。
  • 含動態文字({{ }} / v-text)的元素:照樣注入 id,但加註 data-ab-text-locked,提示 SDK 不可改其文字。
  • v-for 整批共用同一個 id(不支援個別 instance 單獨實驗)。
  • id 為隨機產生:請跑一次、commit,之後勿重跑(重跑會為新元素產新 id;已注入的會跳過、保持不變)。

運作 / 技術

  • @vue/compiler-sfc / @vue/compiler-dom 解析 SFC 與 template AST,精準判斷可注入的元素。
  • magic-string 修改 source:只插入屬性、不重排你的程式碼,保留原始格式。
  • glob 掃描 .vue 檔。

相關