Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iyowei/is-esm
通过 AST 检测 JS 文件是不是 ESM,并非读取 'package.json' 文件中 'type' 设置。
https://github.com/iyowei/is-esm
esm fs iyowei nodejs
Last synced: about 7 hours ago
JSON representation
通过 AST 检测 JS 文件是不是 ESM,并非读取 'package.json' 文件中 'type' 设置。
- Host: GitHub
- URL: https://github.com/iyowei/is-esm
- Owner: iyowei
- License: mit
- Created: 2021-12-17T10:25:41.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-18T07:20:32.000Z (almost 3 years ago)
- Last Synced: 2024-10-29T04:19:06.430Z (10 days ago)
- Topics: esm, fs, iyowei, nodejs
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[node version badge]: https://img.shields.io/badge/node.js-%3E%3D12.20.0-brightgreen?style=flat&logo=Node.js
[download node.js]: https://nodejs.org/en/download/
[prs welcome badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat# isESM(path)
> 通过 AST 检测 JS 文件是不是 ESM,并非读取 "package.json " 文件中 "type" 设置。
## 使用
- `path`,{ String },路径
```js
import { log } from "console";
import { isESM, isESMSync } from "@iyowei/is-esm";(async () => {
log(await isESM("/Users/iyowei/Development/iyowei/create-esm/src/print.js")); // 异步
// truelog(isESMSync("/Users/iyowei/Development/iyowei/create-esm/src/print.js")); // 串行
// true
})();
```## 安装
[![Node Version Badge][node version badge]][download node.js]
```shell
# Pnpm
pnpm add @iyowei/is-esm# yarn
yarn add @iyowei/is-esm# npm
npm add @iyowei/is-esm
```## 参与贡献
![PRs Welcome][prs welcome badge]