Skip to content

Commit

Permalink
chore: repo overall update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 25, 2024
1 parent 1234426 commit cf8788a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion plugins/vite-plugin-canyon/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { parse } from '@babel/parser';
// @ts-ignore
import _traverse from '@babel/traverse';
// @ts-ignore
import _generator from '@babel/generator';

import {visitorProgramExit} from "./visitor-program-exit";
Expand All @@ -14,10 +16,11 @@ function resolveFilename(id: string): string {
return id;
}

export default function VitePluginInstrumentation(serviceParams) {
export default function VitePluginInstrumentation() {
return {
name: 'vite-plugin-instrumentation',
enforce: 'post',
// @ts-ignore
transform(code, id) {
// 解析代码为 AST
const ast = parse(code, {
Expand Down Expand Up @@ -45,6 +48,7 @@ export default function VitePluginInstrumentation(serviceParams) {
// 遍历和修改 AST
traverse(ast, {
Program: {
// @ts-ignore
exit(path) {
// 在 Program 节点的退出时执行
visitorProgramExit(undefined, path, {
Expand Down
1 change: 1 addition & 0 deletions plugins/vite-plugin-canyon/src/visitor-program-exit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {generateInitialCoverage} from "./helpers/generate-initial-coverage";
// import _traverse from '@babel/traverse';
// @ts-ignore
import _generator from '@babel/generator';
import t from '@babel/types';
// const { default: traverse } = _traverse;
Expand Down
17 changes: 14 additions & 3 deletions plugins/vite-plugin-canyon/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"esModuleInterop": true,
"target": "es2018",
"module": "commonjs",
"moduleResolution": "node",
"lib": [ "dom" ],
"rootDir": "src",
"outDir": "dist",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": ["src"]
"include": [ "src/*" ],
"exclude": [ "**/node_modules" ]
}

0 comments on commit cf8788a

Please sign in to comment.