Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit c951902

Browse files
committed
build: source generator for component exports
1 parent 1fcbcba commit c951902

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

packages/c-image/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
"build:types": "tsup src --dts-only"
3131
},
3232
"dependencies": {
33+
"@chakra-ui/styled-system": "2.5.1",
3334
"@chakra-ui/utils": "2.0.15",
3435
"@chakra-ui/vue-system": "workspace:*",
35-
"@chakra-ui/vue-utils": "workspace:*",
36-
"lodash": "4.17.21",
37-
"@chakra-ui/styled-system": "2.5.1"
36+
"@chakra-ui/vue-utils": "workspace:*"
3837
},
3938
"devDependencies": {
4039
"csstype": "^3.1.1",

pnpm-lock.yaml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/utils/exports/inspector.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ function findExports(fileNames: string[], options: ts.CompilerOptions): void {
66

77
const checker = program.getTypeChecker()
88

9-
const namedExports = new Map<string, ts.Symbol["escapedName"][]>()
9+
interface ComponentExport {
10+
name: string
11+
path: string
12+
type: "type" | "variable"
13+
}
14+
15+
const namedExports = new Map<string, ComponentExport[]>()
1016

1117
fileNames.forEach((file) => {
1218
const sourceFile = program.getSourceFile(file)
@@ -17,25 +23,30 @@ function findExports(fileNames: string[], options: ts.CompilerOptions): void {
1723
.getExportsOfModule(sourceFileSymbol)
1824
.filter((symbol) => symbol.escapedName !== "default")
1925
.map((symbol) => {
20-
console.log("symbol", symbol)
21-
22-
return symbol.escapedName
26+
return {
27+
name: symbol.escapedName.toString(),
28+
path: file,
29+
type: symbol.members ? "type" : "variable",
30+
} as ComponentExport
2331
})
2432

2533
namedExports.set(file, exports)
2634
})
2735

2836
namedExports.forEach((exports, file) => {
2937
console.log(`Named exports from ${file}:`)
30-
exports.forEach((exportName) => {
31-
console.log(`- ${exportName}`)
32-
})
38+
exports.forEach(console.log)
3339
})
3440
}
3541

36-
findExports([resolve(__dirname, "./lib-example/index.ts")], {
42+
findExports([resolve(__dirname, "../../../packages/c-icon/src/index.tsx")], {
3743
noEmitOnError: true,
3844
noImplicitAny: true,
3945
target: ts.ScriptTarget.ES5,
4046
module: ts.ModuleKind.CommonJS,
47+
jsx: ts.JsxEmit.Preserve,
4148
})
49+
50+
function findExportsInDirectory(directoryRoot: string) {
51+
// const directory =
52+
}

0 commit comments

Comments
 (0)