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

es6-check-ths

v1.4.0

Published

scan code if contains es6

Downloads

3

Readme

SCAN ES6 CODE

概述

本插件用于检查打包后的前端产物(主要检查以.js结尾的文件)是否包含 ES6 特性,原理是通过 acornestraverse库来解析和遍历代码的语法树,并针对不同的节点类型来判断是否存在 ES6 特性。

acorn的作用:用来将js文件转换成AST语法树,一般要指定要解析的是ES6版本的代码。

estraverse的作用:用来遍历语法树,访问AST语法树的节点,通过各种ES6语法特性的判断,进而确认代码是否包含 ES6 特性。

源代码地址:https://github.com/paulgung/scan-es6-ths

npm包地址:https://www.npmjs.com/package/es6-check-ths

安装依赖

在使用之前,需要安装相关依赖(请提前安装node环境),主要用到了 acornestraverse 库。可以使用以下命令进行安装:

npm install es6-check-ths -g

使用方法

运行命令:

es6-check # 默认扫描dist目录
# 或者
es6-check --path=dist  # dist 是你的指定扫描目录
# 或者
es6-check -p dist  # dist 是你的指定扫描目录

命令行运行效果:

es6-check --path=asd/build
# 文件 /Users/paulgung/WebstormProjects/react-tailwind/asd/build/static/js/787.d9fdfb85.chunk.js 中包含 ES6 语法
# 文件 /Users/paulgung/WebstormProjects/react-tailwind/asd/build/static/js/main.57eda49b.js 中包含 ES6 语法

说明

本插件的主要做了以下的es6特性的检查:

  • 检查常量声明(const)
  • 检查块级作用域变量声明(let)
  • 检查箭头函数
  • 检查模板字面量
  • 解构赋值(数组和对象)
  • 函数默认参数
  • 展开语法(Spread)
  • 迭代器(Iterator)
  • Promise 对象
  • 类定义(ClassDeclaration)
  • 模块化语法(ImportDeclaration、ExportNamedDeclaration、ExportDefaultDeclaration、ExportAllDeclaration)
  • 生成器函数(Generator)
  • async/await
  • 可计算的属性名(Computed Property Name)
  • 模块化的动态导入(Dynamic Import)
  • 默认导出语法
  • 可选链操作符(Optional Chaining)
  • 空值合并操作符(Nullish Coalescing)
  • 类的私有字段语法
  • BigInt 数据类型
  • 数值分隔符
  • 静态类方法
  • Promise.allSettled()
  • 数组的 flat()、flatMap() 方法
  • 字符串模板标签函数(Tagged Template Expression)
  • 对象属性的简写语法
  • 对象属性的计算属性名
  • 剩余参数(Rest Parameters)
  • 默认导出的命名空间导入
  • 尾调用优化
  • 数组解构赋值的默认值
  • 类的静态成员
  • 可迭代对象(Iterable)
  • 解构赋值的嵌套结构
  • 类的扩展和继承语法
  • 对象字面量的简写语法
  • 检查 Set 和 Map 数据结构语法
  • 检查可迭代协议(Iterable Protocol
  • 检查类的私有字段(Private Fields)语法
  • 检查装饰器语法