diff --git a/packages/canyon-data/README.md b/packages/canyon-data/README.md new file mode 100644 index 00000000..2c11d7a8 --- /dev/null +++ b/packages/canyon-data/README.md @@ -0,0 +1,10 @@ +新增代码行,需要传入文件路径 + +```js +const map = { + "/path":{ + add:[0,0,1], + del:[0,0,1] + } +} +``` diff --git a/packages/canyon-data/src/index.ts b/packages/canyon-data/src/index.ts index be5225c7..f93e49f3 100644 --- a/packages/canyon-data/src/index.ts +++ b/packages/canyon-data/src/index.ts @@ -14,3 +14,86 @@ export const genSummaryMapByCoverageMap = (coverageMapData: CoverageMapData):Cov }); return JSON.parse(JSON.stringify(summaryMap)); } + +export const formatCoverageMap = (coverageMapData: CoverageMapData,icwd) => { + return Object.entries(coverageMapData).map(([key, value]) => { + return { + [key.replace(icwd,'~')]: { + ...value, + path: key.replace(icwd,'~'), + }, + } + + }); +} + +export const getSummaryByPath = ( + path: string, + summary: CoverageSummaryMap, +) => { + const summaryObj = libCoverage.createCoverageSummary(); + const filterSummary = Object.keys(summary).reduce((pre: any, cur) => { + if (cur.indexOf(path) === 0) { + pre[cur] = summary[cur]; + } + return pre; + }, {}); + + Object.keys(filterSummary).forEach((item) => { + summaryObj.merge(libCoverage.createCoverageSummary(filterSummary[item])); + }); + return JSON.parse(JSON.stringify(summaryObj)); +}; + +// summary 是总的 +export const genSummaryTreeItem = ( + path: string, + summary: CoverageSummaryMap, +) => { + function check(item: string, path: string) { + if (path === '') { + return true; + } + return item.includes(path); + } + + if (Object.keys(summary).find((item) => item === path)) { + return { + path, + summary: getSummaryByPath(path, summary), + children: [], + }; + } + // 如果是文件夹 + const fileLists: string[] = []; + const folderLists: string[] = []; + + Object.keys(summary).forEach((item) => { + const newpath = path === '' ? item : item.replace(path + '/', ''); + if (check(item, path) && !newpath.includes('/')) { + fileLists.push(item); + } + if (check(item, path) && newpath.includes('/')) { + folderLists.push((path === '' ? '' : path + '/') + newpath.split('/')[0]); + } + }); + + return { + path, + summary: getSummaryByPath(path, summary), + children: [ + ...[...new Set(fileLists)].map((item) => { + return { + path: item, + summary: getSummaryByPath(item, summary), + }; + }), + ...[...new Set(folderLists)].map((item) => { + return { + path: item, + summary: getSummaryByPath(item, summary), + }; + }), + ], + }; +}; diff --git a/packages/canyon-data/src/tests/genSummaryMapByCoverageMap.test.ts b/packages/canyon-data/src/tests/genSummaryMapByCoverageMap.test.ts index a397b86b..3ee23025 100644 --- a/packages/canyon-data/src/tests/genSummaryMapByCoverageMap.test.ts +++ b/packages/canyon-data/src/tests/genSummaryMapByCoverageMap.test.ts @@ -1,8 +1,11 @@ import { expect, test } from 'vitest' -import { genSummaryMapByCoverageMap } from '../index' +import { genSummaryMapByCoverageMap,formatCoverageMap } from '../index' import mockSummaryData from './mock-summary-data.json' import mockCoverageData from './mock-coverage-data.json' - +// import formatCoverageMap from './in' test('generate summary map by coverage map', () => { + + console.log(formatCoverageMap(mockCoverageData,'/builds/canyon/canyon-demo')) + expect(genSummaryMapByCoverageMap(mockCoverageData)).toMatchObject(mockSummaryData) }) diff --git a/packages/canyon-report/src/Report/components/IstanbulReport.tsx b/packages/canyon-report/src/Report/components/IstanbulReport.tsx index a63488af..ea5d07a0 100644 --- a/packages/canyon-report/src/Report/components/IstanbulReport.tsx +++ b/packages/canyon-report/src/Report/components/IstanbulReport.tsx @@ -1,9 +1,30 @@ -import { FC } from 'preact/compat'; +import { genSummaryTreeItem } from '@canyon/data'; +import { FC, useMemo } from 'preact/compat'; import { useEffect, useState } from 'preact/hooks'; import { IstanbulReportProps } from '../types'; +import { Dims, Item, Watermark } from '../types.ts'; +import Th from './Th.tsx'; +import Tr from './Tr.tsx'; -// const dims = ['statements', 'branches', 'functions', 'lines']; +const capitalized = (word: string) => + word.charAt(0).toUpperCase() + word.slice(1); + +const classForPercent = (type: Dims, value: number, _watermarks: any) => { + console.log(type,value,_watermarks) + const watermarks = _watermarks[type]; + if (!watermarks) { + return 'unknown'; + } + if (value < watermarks[0]) { + return 'low'; + } + if (value >= watermarks[1]) { + return 'high'; + } + return 'medium'; +}; +const dims = ['statements', 'branches', 'functions', 'lines']; const IstanbulReport: FC = ({ onSelectFile, watermarks, @@ -12,6 +33,7 @@ const IstanbulReport: FC = ({ console.log(onSelectFile, watermarks); useEffect(() => { const handleSetOptionEvent = (e: { detail: any }) => { + console.log(e.detail, 'e.detail'); setSummary(e.detail); }; @@ -22,8 +44,115 @@ const IstanbulReport: FC = ({ window.removeEventListener('setOptionEvent', handleSetOptionEvent); }; }, []); // 空数组表示仅在组件挂载和卸载时运行 + const [activePath, setActivePath] = useState('/builds/canyon/canyon-demo/src'); + + const summaryTreeItem = useMemo(() => { + return genSummaryTreeItem('/builds/canyon/canyon-demo/src', summary); + }, [activePath, summary]); + const paths = useMemo(() => { + return activePath + .split('/') + .reduce( + (pre: { path: string; name: string }[], cur, currentIndex, array) => { + if (currentIndex !== array.length - 1) { + pre.push({ + path: array.slice(0, currentIndex + 1).join('/'), + name: cur, + }); + } + return pre; + }, + [], + ); + }, [activePath]); + return ( +
+
+

+ { + setActivePath(''); + }} + > + All files + {' '} + /{' '} +
+ {paths.map(({ path, name }) => { + return ( + <> + { + setActivePath(path); + }} + > + {name} + +  /  + + ); + })} +
{' '} + + {summaryTreeItem.path.split('/').at(-1)} + +

+
+ {dims.map((dim) => ( +
+ + {summaryTreeItem.summary[dim].pct}% + + {capitalized(dim)} + + {summaryTreeItem.summary.statements.covered}/ + {summaryTreeItem.summary[dim].total} + +
+ ))} +
+

+ Press n or j to go to the next uncovered block,{' '} + b, p or k for the previous block. +

+
+ Filter: + +
+
+
- return
{JSON.stringify(summary)}
; + {summaryTreeItem.children.length > 0 ? ( +
+ + + {summaryTreeItem.children.map((item) => { + return ( + { + setActivePath(p); + }} + path={item.path} + item={item.summary} + watermarks={watermarks} + /> + ); + })} + +
+
+
+ ) : ( +
wu
+ )} +
+ ); }; export default IstanbulReport; diff --git a/packages/canyon-report/src/Report/components/Th.tsx b/packages/canyon-report/src/Report/components/Th.tsx new file mode 100644 index 00000000..87c44d87 --- /dev/null +++ b/packages/canyon-report/src/Report/components/Th.tsx @@ -0,0 +1,91 @@ +const Th = () => { + return ( + + + + File + + + + + + + Statements + + + + + + + Branches + + + + + + + Functions + + + + + + + Lines + + + + + + + + ); +}; + +export default Th; diff --git a/packages/canyon-report/src/Report/components/Tr.tsx b/packages/canyon-report/src/Report/components/Tr.tsx new file mode 100644 index 00000000..40f74d13 --- /dev/null +++ b/packages/canyon-report/src/Report/components/Tr.tsx @@ -0,0 +1,91 @@ +import { FC } from 'preact/compat'; + +// import { classForPercent } from '../helpers.ts'; +import {Dims, TrProps, Watermarks} from '../types.ts'; +const classForPercent = ( + type: Dims, + value: number, + _watermarks: Watermarks, +) => { + console.log(type,value,_watermarks) + const watermarks = _watermarks[type]; + if (!watermarks) { + return 'unknown'; + } + if (value < watermarks[0]) { + return 'low'; + } + if (value >= watermarks[1]) { + return 'high'; + } + return 'medium'; +}; + +const Tr: FC = ({ path, item, watermarks, setActivePath }) => { + return ( + + + { + setActivePath(path); + }} + > + {path.split('/').at(-1)} + + + + +
+
+
+
+ + + {Object.values(Dims).map((value) => { + return ( + <> + + {item[value].pct}% + + + {item[value].covered}/{item[value].total} + + + ); + })} + + ); +}; + +export default Tr; diff --git a/packages/canyon-report/src/code.css b/packages/canyon-report/src/code.css new file mode 100644 index 00000000..ab4ecbfe --- /dev/null +++ b/packages/canyon-report/src/code.css @@ -0,0 +1,20 @@ +.box{ + border: 20px solid white; + border-left: none; + margin: 0; + position: relative; +} + +.box pre{ + position: relative; + z-index: 2; +} + +.box pre code.hljs{ + padding: 0 !important; + background-color: unset !important; +} + +.box pre code .hljs-tag{ + background-color: unset !important; +} \ No newline at end of file diff --git a/packages/canyon-report/src/index.css b/packages/canyon-report/src/index.css new file mode 100644 index 00000000..f650de31 --- /dev/null +++ b/packages/canyon-report/src/index.css @@ -0,0 +1,406 @@ +html,body{ + margin: 0; + padding: 0; +} +#canyon-report { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color: #333; +} + +#canyon-report .small { + font-size: 12px; +} + +#canyon-report *, +#canyon-report *:after, +#canyon-report *:before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +#canyon-report h1 { + font-size: 20px; + margin: 0; +} + +#canyon-report h2 { + font-size: 14px; +} + +#canyon-report pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} + +#canyon-report a { + color: #0074D9; + text-decoration: none; + cursor: pointer; +} + +#canyon-report a:hover { + text-decoration: underline; +} + +#canyon-report .strong { + font-weight: bold; +} + +#canyon-report .space-top1 { + padding: 10px 0 0 0; +} + +#canyon-report .pad2y { + padding: 20px 0; +} + +#canyon-report .pad1y { + padding: 10px 0; +} + +#canyon-report .pad2x { + padding: 0 20px; +} + +#canyon-report .pad2 { + padding: 20px; +} + +#canyon-report .pad1 { + padding: 10px; +} + +#canyon-report .space-left2 { + padding-left: 55px; +} + +#canyon-report .space-right2 { + padding-right: 20px; +} + +#canyon-report .center { + text-align: center; +} + +#canyon-report .clearfix { + display: block; +} + +#canyon-report .clearfix:after { + content: ''; + display: block; + height: 0; + clear: both; + visibility: hidden; +} + +#canyon-report .fl { + float: left; +} + +@media only screen and (max-width: 640px) { + #canyon-report .col3 { + width: 100%; + max-width: 100%; + } + + #canyon-report .hide-mobile { + display: none !important; + } + +} + +#canyon-report .quiet { + color: #7f7f7f; + color: rgba(0, 0, 0, 0.5); +} + +#canyon-report .quiet a { + opacity: 0.7; +} + +#canyon-report .fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +#canyon-report div.path a:link, +#canyon-report div.path a:visited { + color: #333; +} + +#canyon-report table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +#canyon-report table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} + +#canyon-report table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} + +#canyon-report table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width: 20px; +} + +#canyon-report table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} + +#canyon-report .missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +#canyon-report .skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} + +#canyon-report .missing-if-branch .typ, +#canyon-report .skip-if-branch .typ { + color: inherit !important; +} + +#canyon-report .coverage-summary { + border-collapse: collapse; + width: 100%; +} + +#canyon-report .coverage-summary tr { + border-bottom: 1px solid #bbb; +} + +#canyon-report .keyline-all { + border: 1px solid #ddd; +} + +#canyon-report .coverage-summary td, +#canyon-report .coverage-summary th { + padding: 10px; +} + +#canyon-report .coverage-summary tbody { + border: 1px solid #bbb; +} + +#canyon-report .coverage-summary td { + border-right: 1px solid #bbb; +} + +#canyon-report .coverage-summary td:last-child { + border-right: none; +} + +#canyon-report .coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} + +#canyon-report .coverage-summary th.file { + border-right: none !important; +} + +#canyon-report .coverage-summary th.pic, +#canyon-report .coverage-summary th.abs, +#canyon-report .coverage-summary td.pct, +#canyon-report .coverage-summary td.abs { + text-align: right; +} + +#canyon-report .coverage-summary td.file { + white-space: nowrap; +} + +#canyon-report .coverage-summary td.pic { + min-width: 120px !important; +} + +#canyon-report .coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + /*background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;*/ +} + +#canyon-report .coverage-summary .sorted .sorter { + background-position: 0 -20px; +} + +#canyon-report .coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} + +#canyon-report .status-line { + height: 10px; +} + +#canyon-report .cbranch-no { + background: yellow !important; + color: #111; +} + +#canyon-report .red.solid, +#canyon-report .status-line.low, +#canyon-report .low .cover-fill { + background: #c21f39; +} + +#canyon-report .low .chart { + border: 1px solid #c21f39; +} + +#canyon-report .highlighted, +#canyon-report .highlighted .cstat-no, +#canyon-report .highlighted .fstat-no, +#canyon-report .highlighted .cbranch-no { + background: #C21F39 !important; +} + +#canyon-report .cstat-no, +#canyon-report .fstat-no, +#canyon-report .cbranch-no, +#canyon-report .cbranch-no { + background: #f6c6ce; +} + +#canyon-report .low, +#canyon-report .cline-no { + background: #fce1e5; +} + +#canyon-report .high, +#canyon-report .cline-yes { + background: #e6f5d0; +} + +#canyon-report .cstat-yes { + background: #a1d76a; +} + +#canyon-report .status-line.high, +#canyon-report .high .cover-fill { + background: #4d9221; +} + +#canyon-report .high .chart { + border: 1px solid #4d9221; +} + +#canyon-report .status-line.medium, +#canyon-report .medium .cover-fill { + background: #f9cd0b; +} + +#canyon-report .medium .chart { + border: 1px solid #f9cd0b; +} + +#canyon-report .medium { + background: #fff4c2; +} + +#canyon-report .cstat-skip { + background: #ddd; + color: #111; +} + +#canyon-report .fstat-skip { + background: #ddd; + color: #111 !important; +} + +#canyon-report .cbranch-skip { + background: #ddd !important; + color: #111; +} + +#canyon-report span.cline-neutral { + background: #eaeaea; +} + +#canyon-report .coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +#canyon-report .cover-fill, +#canyon-report .cover-empty { + display: inline-block; + height: 12px; +} + +#canyon-report .chart { + line-height: 0; +} + +#canyon-report .cover-empty { + background: white; +} + +#canyon-report .cover-full { + border-right: none !important; +} + +#canyon-report pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} + +#canyon-report .com { + color: #999 !important; +} + +#canyon-report .ignore-none { + color: #999; + font-weight: normal; +} + +#canyon-report .wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} + +#canyon-report .footer, +#canyon-report .push { + height: 48px; +} \ No newline at end of file diff --git a/packages/canyon-report/src/main.tsx b/packages/canyon-report/src/main.tsx index c0e776d3..e165975f 100644 --- a/packages/canyon-report/src/main.tsx +++ b/packages/canyon-report/src/main.tsx @@ -1,6 +1,15 @@ +// import { summary } from './mock'; +import { genSummaryMapByCoverageMap } from '@canyon/data'; +import './index.css' +import './code.css' import { init } from './index'; -import { summary } from './mock'; - +import mockCoverageData from './mock-coverage-data.json' +const configWatermarks = { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], +}; const report = init(document.querySelector('#root') as any, { onSelectFile(path: string) { console.log(path); @@ -8,6 +17,6 @@ const report = init(document.querySelector('#root') as any, { resolve(1); }); }, - watermarks:[] as any, + watermarks: configWatermarks, }); -report.setOption({ summary }); +report.setOption({ summary: genSummaryMapByCoverageMap(mockCoverageData) }); diff --git a/packages/canyon-report/src/mock-coverage-data.json b/packages/canyon-report/src/mock-coverage-data.json new file mode 100644 index 00000000..bfcdff24 --- /dev/null +++ b/packages/canyon-report/src/mock-coverage-data.json @@ -0,0 +1,536 @@ +{ + "/builds/canyon/canyon-demo/src/pages/Welcome.tsx": { + "path": "/builds/canyon/canyon-demo/src/pages/Welcome.tsx", + "statementMap": { + "0": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "1": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 30 + } + }, + "2": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "3": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 20 + } + } + }, + "fnMap": { + "0": { + "name": "(anonymous_0)", + "decl": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "line": 3 + }, + "1": { + "name": "(anonymous_1)", + "decl": { + "start": { + "line": 6, + "column": 21 + }, + "end": { + "line": 6, + "column": 22 + } + }, + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "line": 6 + } + }, + "branchMap": {}, + "s": { + "0": 1, + "1": 0, + "2": 0, + "3": 0 + }, + "f": { + "0": 0, + "1": 0 + }, + "b": {}, + "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9", + "hash": "44a06ed36306fbbfd189234db0541dd6d0488999" + }, + "/builds/canyon/canyon-demo/src/pages/Home.tsx": { + "path": "/builds/canyon/canyon-demo/src/pages/Home.tsx", + "statementMap": { + "0": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 41 + } + }, + "1": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 27 + } + }, + "2": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "3": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 39 + } + }, + "4": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 37 + } + }, + "5": { + "start": { + "line": 12, + "column": 12 + }, + "end": { + "line": 12, + "column": 31 + } + }, + "6": { + "start": { + "line": 15, + "column": 4 + }, + "end": { + "line": 35, + "column": 5 + } + }, + "7": { + "start": { + "line": 18, + "column": 64 + }, + "end": { + "line": 18, + "column": 94 + } + }, + "8": { + "start": { + "line": 18, + "column": 84 + }, + "end": { + "line": 18, + "column": 93 + } + }, + "9": { + "start": { + "line": 24, + "column": 20 + }, + "end": { + "line": 24, + "column": 53 + } + }, + "10": { + "start": { + "line": 29, + "column": 20 + }, + "end": { + "line": 29, + "column": 43 + } + } + }, + "fnMap": { + "0": { + "name": "Home", + "decl": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 36, + "column": 1 + } + }, + "line": 3 + }, + "1": { + "name": "tips", + "decl": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 17 + } + }, + "loc": { + "start": { + "line": 7, + "column": 28 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "line": 7 + }, + "2": { + "name": "(anonymous_2)", + "decl": { + "start": { + "line": 18, + "column": 58 + }, + "end": { + "line": 18, + "column": 59 + } + }, + "loc": { + "start": { + "line": 18, + "column": 64 + }, + "end": { + "line": 18, + "column": 94 + } + }, + "line": 18 + }, + "3": { + "name": "(anonymous_3)", + "decl": { + "start": { + "line": 18, + "column": 73 + }, + "end": { + "line": 18, + "column": 74 + } + }, + "loc": { + "start": { + "line": 18, + "column": 84 + }, + "end": { + "line": 18, + "column": 93 + } + }, + "line": 18 + }, + "4": { + "name": "(anonymous_4)", + "decl": { + "start": { + "line": 23, + "column": 45 + }, + "end": { + "line": 23, + "column": 46 + } + }, + "loc": { + "start": { + "line": 23, + "column": 49 + }, + "end": { + "line": 25, + "column": 17 + } + }, + "line": 23 + }, + "5": { + "name": "(anonymous_5)", + "decl": { + "start": { + "line": 28, + "column": 46 + }, + "end": { + "line": 28, + "column": 47 + } + }, + "loc": { + "start": { + "line": 28, + "column": 50 + }, + "end": { + "line": 30, + "column": 17 + } + }, + "line": 28 + } + }, + "branchMap": { + "0": { + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "type": "if", + "locations": [ + { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 13, + "column": 9 + } + } + ], + "line": 8 + } + }, + "s": { + "0": 1, + "1": 1, + "2": 1, + "3": 0, + "4": 1, + "5": 1, + "6": 1, + "7": 0, + "8": 0, + "9": 0, + "10": 0 + }, + "f": { + "0": 1, + "1": 1, + "2": 0, + "3": 0, + "4": 0, + "5": 0 + }, + "b": { + "0": [ + 0, + 1 + ] + }, + "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9", + "hash": "94acebb40f91fa6aab2be22d5f32d9b020aefe85" + }, + "/builds/canyon/canyon-demo/src/routers/index.tsx": { + "path": "/builds/canyon/canyon-demo/src/routers/index.tsx", + "statementMap": {}, + "fnMap": {}, + "branchMap": {}, + "s": {}, + "f": {}, + "b": {}, + "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9", + "hash": "331bbffdd38304ac26edcd0f159b967d23f5bdcd" + }, + "/builds/canyon/canyon-demo/src/App.tsx": { + "path": "/builds/canyon/canyon-demo/src/App.tsx", + "statementMap": { + "0": { + "start": { + "line": 7, + "column": 26 + }, + "end": { + "line": 7, + "column": 49 + } + }, + "1": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 12, + "column": 3 + } + } + }, + "fnMap": { + "0": { + "name": "App", + "decl": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "line": 6 + } + }, + "branchMap": {}, + "s": { + "0": 1, + "1": 1 + }, + "f": { + "0": 1 + }, + "b": {}, + "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9", + "hash": "1454065cc7fb2c09d5dcdbb82b046335a719923d" + }, + "/builds/canyon/canyon-demo/src/main.tsx": { + "path": "/builds/canyon/canyon-demo/src/main.tsx", + "statementMap": { + "0": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 12, + "column": 1 + } + } + }, + "fnMap": {}, + "branchMap": {}, + "s": { + "0": 1 + }, + "f": {}, + "b": {}, + "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9", + "hash": "2ca7e398b7e7ea1ee9480ada2f5111a10d111593" + } +} diff --git a/packages/canyon-report/tsconfig.decl.json b/packages/canyon-report/tsconfig.decl.json index 15058ea1..95e7796b 100644 --- a/packages/canyon-report/tsconfig.decl.json +++ b/packages/canyon-report/tsconfig.decl.json @@ -16,6 +16,7 @@ "moduleResolution": "node", "jsx": "react-jsx", "jsxImportSource": "preact", + "resolveJsonModule": true, "esModuleInterop": true }, diff --git a/packages/canyon-report/vite.config.ts b/packages/canyon-report/vite.config.ts index 016adb99..f6c37c16 100644 --- a/packages/canyon-report/vite.config.ts +++ b/packages/canyon-report/vite.config.ts @@ -1,19 +1,26 @@ -import { defineConfig } from 'vite' -import preact from '@preact/preset-vite' -import {resolve} from "path"; +import preact from '@preact/preset-vite'; +import { resolve } from 'path'; +import { defineConfig } from 'vite'; +import * as path from "path"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [preact()], + resolve: { + alias: { + '@canyon/data': path.resolve('../canyon-data/src'), + // '@': path.resolve(__dirname, './src'), + }, + }, build: { - outDir: "./dist", + outDir: './dist', emptyOutDir: true, - commonjsOptions:{}, + commonjsOptions: {}, lib: { - entry: resolve(__dirname, "src/index.ts"), - fileName: "canyon-report", - name:"CanyonReport", - formats: ["es", "cjs",'umd'], + entry: resolve(__dirname, 'src/index.ts'), + fileName: 'canyon-report', + name: 'CanyonReport', + formats: ['es', 'cjs', 'umd'], }, }, -}) +});