基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/videojs/v10 --skill transform-rolldown-code命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | transform-rolldown-code |
| description | Transform code. Use for Rolldown. |
Use the incoming Oxc AST for analysis and its paired MagicString for source edits.
code.includes(...) guard before accessing meta.ast so parsing stays lazy.meta.ast only when syntax analysis is required. It is a read-only Oxc Program parsed according to meta.moduleType and supports JavaScript, JSX, TypeScript, and TSX syntax.start and end offsets with meta.magicString.overwrite, remove, appendLeft, or related edits. Both values describe the same incoming code string.{ code: magicString }. Edits are ignored when the hook does not return it. Return null when nothing changed.transform. Use renderChunk only when the replacement depends on final generated code, chunk filenames, output format, or the rendered chunk graph; never move ordinary AST transforms there.Treat meta.ast as read-only. Mutating its nodes does not change output because Rolldown does not print the modified JavaScript AST.
The Oxc AST is syntactic. It includes TS and TSX nodes but has no TypeScript Program, TypeChecker, resolved symbols, inferred types, or cross-file semantics.
For true AST-to-AST transforms, use an appropriate parser, transformer, and code generator, then return generated code with a source map. Every source-changing transform should provide a map unless it intentionally documents a sourceMap: false option; returning native MagicString provides one automatically. Use map: null only when the edit does not move code.
Treat meta.ast and meta.magicString as a required contract in repository-owned Rolldown builds and fail clearly when either is unexpectedly unavailable. Only synthesize or guard the metadata in an intentional compatibility adapter, such as the Vite adapter.
Explicitly enable Rolldown's native implementation in every repository-owned input config that runs these transforms:
experimental: {
nativeMagicString: true,
}
For tsdown, put the same option under inputOptions.experimental. Keep returning the native object directly so Rolldown can generate and compose source maps off the main thread. Enable output sourcemap: true when the build should emit map files. See the native MagicString guide and source transformation guide.
Vite does not forward Rolldown's ast or magicString transform metadata in the pinned version, even when its build enables native MagicString. Continue to adapt these transforms through packages/vjsc/src/vite/oxc.ts for Vite serve and build.
import { walk } from 'oxc-walker';
export const plugin = {
name: 'example-transform',
transform(code, id, meta) {
if (!code.includes('$compile')) return null;
const ast = meta.ast;
const magicString = meta.magicString;
if (!ast || !magicString) {
throw new Error('example-transform requires Rolldown AST metadata and native MagicString.');
}
let changed = false;
walk(ast, {
enter(node) {
if (
node.type === 'CallExpression' &&
node.callee.type === 'Identifier' &&
node.callee.name === '$compile'
) {
magicString.overwrite(node.callee.start, node.callee.end, 'compile');
changed = true;
}
},
});
return changed ? { code: magicString } : null;
},
};
Think of the hook as:
incoming code
-> Oxc AST: find and understand syntax
-> MagicString: edit source using AST ranges
-> return edited code
Run the transform through a real Rolldown build with native MagicString explicitly enabled. Assert changed and unchanged modules, relevant JS/JSX/TS/TSX forms, source maps when consumers need them, and a clear failure when required metadata is unavailable.
Input: "Rename $compile() calls without changing matching strings or comments."
Output: A filtered transform that finds call expressions through meta.ast, overwrites the callee ranges through meta.magicString, returns the edited value, and passes a real Rolldown build test.
Write generated Video.js API reference pages. Use for components, hooks, controllers, factories, builder compatibility, demos, or extracted JSDoc.
Create VJSC modules. Use for UI and styles.
Implement an SPF use-case composition. Use when a delivery scenario combines feature variants and requires composition, tests, and status updates.