rollup-ast-parser
2024年01月08日
一、认识
二、安装
pnpm install tsup -D
三、配置
3.1 编译配置
根目录新建 tsup.config.ts
, 配置如下:
import { defineConfig } from "tsup";
export default defineConfig({
entry: {
tokenizer: "src/tokenizer.ts",
},
format: ["esm", "cjs"],
target: "es2020",
sourcemap: true,
splitting: false,
});
根目录新建 tsconfig.json
, 配置如下:
{
"compilerOptions": {
"target": "es2016",
"allowJs": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"sourceMap": true,
"composite": true,
"baseUrl": "src",
"rootDir": "src",
"declaration": true
},
"include": ["src"],
"exclude": ["__test__"]
}
3.2 命令配置
"scripts": {
"start": "tsup --watch"
}
四、测试
创建 src/tokenizer.ts
, 代码如下:
const name: string = "嘻嘻";
console.log("name",name);