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 🙏

© 2024 – Pkg Stats / Ryan Hefner

venus-scripts

v1.4.33

Published

webpack build scripts & utils for all FE scaffolds build

Downloads

114

Readme

venus-scripts

前期准备工作

  • 项目的开发目录要求
  - src
    + index.ts
  - tests
    + index.test.ts
  - package.json
  - README.md
  - index.js
  - packages
    + project
      - src
        + index.ts
      - tests
        + index.test.ts
      - package.json
      - README.md
      - index.js
    + project2
    - src
      + index.ts
    - tests
      + index.test.ts
    - package.json
    - README.md
    - index.js
  - lerna.json
  - package.json
  • package.json 增加rollup配置
"scripts": {
  "bootstrap": "venus-scripts bootstrap",
  "build": "venus-scripts build -- --cjs",
  "test": "venus-scripts test",
  "lint": "tslint -p tsconfig.json",
  "circularDeps": "madge --circular src/index.ts"
},
"main": "index.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"files": [
  "dist/",
  "index.js",
  "README.md",
  "package.json"
],
"pre-commit": {
  "silent": true,
  "run": [
    "circularDeps",
    "lint",
    "test"
  ]
},
"publishConfig": {
  "registry": "http://npm.venus.org/",
  "access": "public"
},
"rollup": {
  // 嵌入到打包bundle文件中的依赖包
  "bundledDependencies": [],
  // 支持编译类型枚举: 'cjs'|'esm'|'umd'  
  "buildTypes": [
    "cjs", "esm"
  ],
  // import {} from 'inferno' Inferno直接通过全局引入的方式放到了window.Inferno上面则需要配置moduleGlobals.
  "moduleGlobals": {"inferno": "Inferno"},
  // umd模式下的全局命名空间, 注意只有当库有export 的模块才有此概念
  "moduleName": "venus.scripts"
},
  • 配置npm-scripts
"scripts": {
  "build": "venus-scripts build --cjs",
  "bootstrap": "venus-scripts bootstrap",
  "test": "venus-scripts test",
  "lint": "tslint -p tsconfig.json --project",
  "circularDeps": "madge --circular src/index.ts"
}

运营相关命令顺序,以及关键点

    1. 在项目中安装venus-scripts包依赖
    1. 执行npm run bootstrap
    1. 执行npm run build 编译当前库项目(注意这里不适合用来编译webpack业务项目)
  • npm run build -- --cjs
  • npm run build -- --umd
  • npm run build -- --esm
  • npm run build -- --replace
  • npm run build -- --sourcemap
  • npm run build -- --rem=false -禁止转换px到rem
    1. 执行npm run test 测试相关脚本 npm run test -- index.test.ts
    1. 如果需要利用vscode调试,请修改.vscode文件夹中相关配置

拓展自定义babel-plugin-*

  1. create venus.config.js, 比如增加infernojs的编译插件可以类似如下(自行安装相关依赖)
module.exports = {
  rollupAlias: {},
  rollupRemOption: { rootValue: 100, unitPrecision: 5, minPixelValue: 1.1 },
  rollupRpxOption: { rootValue: 1, unitPrecision: 5, minPixelValue: 0 },
  rollupSourcemapPathTransform: (sourcePath, pkgName)=> string,
  rollupCssAssetsCDN: [],
  babel: {
    plugins: [
      ["babel-plugin-inferno", {"imports": true}]
    ]
  }
}

index.js

'use strict';

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./dist/index.cjs.min.js');
} else {
  module.exports = require('./dist/index.cjs.js');
}

module.exports.default = module.exports;

注意事项

  1. 默认tsconfig.json 中会配置为allowJs: false 禁用对.js的支持,默认我们都需要用ts,tsx来书写代码如果特殊情况需要请自行打开allowJs:true