Skip to content
/ is-esm Public

通过 AST 检测 JS 文件是不是 ESM,并非读取 'package.json' 文件中 'type' 设置。

License

Notifications You must be signed in to change notification settings

iyowei/is-esm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

isESM(path)

通过 AST 检测 JS 文件是不是 ESM,并非读取 "package.json " 文件中 "type" 设置。

使用

  • path,{ String },路径
import { log } from "console";
import { isESM, isESMSync } from "@iyowei/is-esm";

(async () => {
  log(await isESM("/Users/iyowei/Development/iyowei/create-esm/src/print.js")); // 异步
  // true

  log(isESMSync("/Users/iyowei/Development/iyowei/create-esm/src/print.js")); // 串行
  // true
})();

安装

Node Version Badge

# Pnpm
pnpm add @iyowei/is-esm

# yarn
yarn add @iyowei/is-esm

# npm
npm add @iyowei/is-esm

参与贡献

PRs Welcome

About

通过 AST 检测 JS 文件是不是 ESM,并非读取 'package.json' 文件中 'type' 设置。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published