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

@weapp-vite/ast

v6.11.9

Published

weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作

Downloads

2,078

Readme

@weapp-vite/ast

简介

@weapp-vite/ast 提供 weapp-vite 体系内可复用的 AST 解析与静态分析能力,统一封装 Babel 与 Oxc 两套后端,并抽出跨包共享的分析操作,供 weapp-vitewevu@wevu/compiler 等包复用。

特性

  • 统一的 Babel / Oxc 解析入口
  • JS / TS / JSX / TSX 源码解析
  • 平台 API、requirescript setup import 等轻量分析
  • 组件 props、特性标记、JSX 自动组件等共享分析操作
  • 面向业务包的可参数化分析器,避免重复实现

安装

pnpm add @weapp-vite/ast

使用

解析源码:

import { parseJsLikeWithEngine } from '@weapp-vite/ast'

const babelAst = parseJsLikeWithEngine('export const value = 1')
const oxcAst = parseJsLikeWithEngine('export const value = 1', {
  engine: 'oxc',
  filename: 'inline.ts',
})

收集通用特性标记:

import { collectFeatureFlagsFromCode } from '@weapp-vite/ast'

const flags = collectFeatureFlagsFromCode(code, {
  astEngine: 'oxc',
  moduleId: 'wevu',
  hookToFeature: {
    onLoad: 'enableShare',
    onShow: 'enableShow',
  },
})

收集 JSX 自动组件:

import { collectJsxAutoComponentsFromCode } from '@weapp-vite/ast'

const result = collectJsxAutoComponentsFromCode(code, {
  astEngine: 'babel',
  isCollectableTag(tag) {
    return !['view', 'text'].includes(tag)
  },
  isDefineComponentSource(source) {
    return source === 'vue' || source === 'wevu'
  },
})

稳定 API

建议优先从根入口导入稳定 API:

  • parseJsLikeWithEngine
  • collectComponentPropsFromCode
  • collectFeatureFlagsFromCode
  • collectJsxAutoComponentsFromCode
  • collectJsxImportedComponentsAndDefaultExportFromBabelAst
  • collectJsxTemplateTagsFromBabelExpression
  • mayContainPlatformApiAccess
  • collectRequireTokens
  • collectScriptSetupImportsFromCode
  • unwrapTypeScriptExpression
  • getObjectPropertyByKey
  • getRenderPropertyFromComponentOptions
  • resolveRenderExpressionFromComponentOptions

子路径导出

如果需要更细粒度地按能力引用,也可以使用这些子路径导出:

  • @weapp-vite/ast/babel
  • @weapp-vite/ast/babelNodes
  • @weapp-vite/ast/engine
  • @weapp-vite/ast/types
  • @weapp-vite/ast/operations/componentProps
  • @weapp-vite/ast/operations/featureFlags
  • @weapp-vite/ast/operations/jsxAutoComponents
  • @weapp-vite/ast/operations/platformApi
  • @weapp-vite/ast/operations/require
  • @weapp-vite/ast/operations/scriptSetupImports

默认建议:

  • 业务侧优先使用根入口
  • 只有在需要低层 helper 或做更细粒度 tree-shaking 时,再使用子路径导入

发布校验

包内可直接运行以下命令做独立校验:

pnpm build
pnpm test
pnpm run check:release

相关链接

  • 文档:https://vite.icebreaker.top/
  • 仓库:https://github.com/weapp-vite/weapp-vite