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

alpaca-sm

v2.1.2

Published

分析Html文件依赖的js文件和css文件

Readme

alpaca-sm

针对sm公司业务定制的用于模块化解析的工具。 因公司前端业务框架的原因,前端开发不能使用市面上的模块化类库,如seajs,requireJs,modJs等。 此工具是在编译阶段,将采用commonJS规范的模块化代码,转译成闭包形式的代码。

USAGE

安装

npm install alpaca-sm -g

API说明

####config

  • 解释:管理配置项
  • 用法:
    alp.config.get('ns');
    alp.config.get('readable.css');
    alp.config.set('ns');

####processor

  • 解释:分析文件的依赖项
  • 参数: src: 文件的绝对路径,重要的事说三遍,绝对路径!绝对路径!绝对路径! contentProcessor: 文件内容处理器,返回处理过后的文件内容。
  • 用法:
        alp.processor({
            src: file.realpath,
            contentProcessor: function (file) {
                var retObj;
    
                retObj = ret.src['/' + file.subpath];
                if (retObj) {
                    return retObj.rawContent || retObj.getContent();
                } else {
                    return file.getContent();
                }
            }
        });
    

配置说明

####ns 解释:生成闭包后,所使用的命名空间 类型: string 默认值:'ns' ####root 解释:项目的根目录 类型:string 默认值:当前目录 说明:注意配置项fileBasedRoot对他的影响 ####fileBasedRoot 解释:js文件中使用require的路径是否是基于root的。 类型:boolean 默认值:false 说明:主要用于应对使用构建工具生成的文件,路径会被编译为基于项目root的相对路径,如fis ####exclude 解释:排除一些已存在的使用require关键字的文件,比如用webpack或browerify打包的文件 类型:array | string | RegExp 默认值:[] ####include 解释:命中的文件才会被处理 类型:array | string | RegExp 默认值:[] ####isOptimizer 解释:分析的文件是否是被压缩过的文件 类型:boolean 默认值:false 说明:压缩过的文件和没压缩过的文件,代码结构不同,不能使用同一种处理方法。 ####wrapJsInHtml 解释:是否对html中的js代码添加闭包代码 类型:boolean 默认值:false 说明:如果代码中的require参与运算的话,就忽略该值,为代码加上闭包。 ####readable.css 解释:在js中出现requrie('../xx.css')时,是否读取css文件的内容 类型:boolean 默认值:false ####readable.cssInHtml(已废弃) 解释:在HTML文件的script标签使用require('../xx.css')是,是否读取css的内容 类型:boolean 默认值:false

####tmpl 解释:css和js的引入模板