Parjs 项目教程
parjs JavaScript parser-combinator library 项目地址: https://gitcode.com/gh_mirrors/pa/parjs
1. 项目的目录结构及介绍
/
├── dist/
│ ├── spec/
│ └── (compiled from /src)
├── dist-spec/
│ └── (compiled from /spec)
├── examples/ // 未使用
├── package.json
├── tsconfig.json
├── README.md // char-info readme
├── tsconfig.base.json // 所有 emitting tsconfigs 的扩展基础
├── tsconfig.json // 链接至 packages/[char-info, parjs]/tsconfig.json
├── package.json // 工作区 package.json 文件
├── (linting configurations)
├── jest.root.mjs // 基础 jest 配置
├── yarn.lock // 工作区 yarn.lock 文件
├── README.md // monorepo readme
├── parjs.code-workspace
└── .git*
目录结构介绍
- dist/: 编译后的文件,包含从
/src
编译的文件。 - dist-spec/: 编译后的测试文件,包含从
/spec
编译的文件。 - examples/: 示例文件夹,当前未使用。
- package.json: 项目的包管理文件。
- tsconfig.json: TypeScript 配置文件,链接至
packages/[char-info, parjs]/tsconfig.json
。 - README.md: 项目的 README 文件,包含项目的基本信息。
- tsconfig.base.json: 所有 emitting tsconfigs 的扩展基础。
- package.json: 工作区的包管理文件。
- (linting configurations): 代码风格和格式化配置文件。
- jest.root.mjs: 基础的 Jest 测试配置文件。
- yarn.lock: 工作区的 yarn.lock 文件,用于锁定依赖版本。
- README.md: monorepo 的 README 文件,包含 monorepo 的基本信息。
- parjs.code-workspace: VS Code 工作区文件,用于管理多个包。
- .git*: Git 相关文件。
2. 项目的启动文件介绍
项目的启动文件主要是 package.json
中的 scripts
部分,用于定义项目的启动、构建和测试命令。以下是一些常见的启动命令:
{
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"test": "jest"
}
}
启动文件介绍
- start: 启动项目,通常指向编译后的入口文件
dist/index.js
。 - build: 使用 TypeScript 编译器
tsc
编译项目。 - test: 使用 Jest 运行测试。
3. 项目的配置文件介绍
tsconfig.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
tsconfig.base.json
{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
package.json
{
"name": "parjs",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"test": "jest"
},
"dependencies": {
"typescript": "^4.0.0"
},
"devDependencies": {
"jest": "^26.0.0"
}
}
配置文件介绍
- tsconfig.json: TypeScript 编译器配置文件,继承自
tsconfig.base.json
,定义了编译输出目录outDir
和源代码目录rootDir
。 - tsconfig.base.json: 基础的 TypeScript 编译器配置文件,定义了编译目标、模块系统、严格模式等。
- package.json: 项目的包管理文件,定义了项目名称、版本、入口文件、脚本命令、依赖和开发依赖。
通过以上配置文件,可以实现项目的编译、启动和测试。
parjs JavaScript parser-combinator library 项目地址: https://gitcode.com/gh_mirrors/pa/parjs