Package boundaries
Package Boundary Separation
Eliminate TS6059 errors across packages/vue and packages/core.
Problem
Vue package's tsconfig.build.json (rootDir: "src") imported core source files directly via path aliases:
{
"paths": {
"@363045841yyt/klinechart-core": ["../core/src"]
}
}This dragged packages/core/src/** into Vue's TypeScript compilation scope. Since rootDir: "src"
limited the compilation to packages/vue/src/**, every import of core source triggered:
TS6059: File '.../packages/core/src/...' is not under 'rootDir' '.../packages/vue/src'The errors propagated through the import chain — a single import from vue/src/index.ts →
@363045841yyt/klinechart-core → core/src/index.ts → its re-exports → their dependencies →
all the way down, producing ~40 errors per run.
A secondary issue: MarkerTooltip.vue imported core types using a raw relative path to packages/core:
import type { MarkerEntity, CustomMarkerEntity } from '../../../core/src/engine/marker/registry'This bypasses both the package name and the workspace symlink.
Solution
1. Remove core source path aliases
Both tsconfig.json (dev) and tsconfig.build.json (build) no longer alias
@363045841yyt/klinechart-core to ../core/src.
TypeScript resolves @363045841yyt/klinechart-core through pnpm's workspace symlink:
packages/vue/node_modules/@363045841yyt/klinechart-core
→ packages/core (symlink)
→ package.json exports.types → ./dist/index.d.tsThe Vue package now sees only core's built declaration files, not its raw source.
This eliminates the rootDir violation and enforces a clean API boundary.
2. Add missing core export
Added "./engine/marker/registry" to packages/core/package.json exports so the
MarkerTooltip component can import through the package name:
import type { MarkerEntity, CustomMarkerEntity } from '@363045841yyt/klinechart-core/engine/marker/registry'3. Remove duplicate copyFile
Vue's package.json had the same copyFileSync in both build and postbuild. Kept
only postbuild, which runs automatically after vite build.
4. Workspace build command
Added build:packages to root package.json:
"build:packages": "pnpm --filter @363045841yyt/klinechart-core build && pnpm --filter @363045841yyt/klinechart build"Builds core first, then Vue — mirroring the production dependency order.
Files Changed
| File | Change |
|---|---|
packages/vue/tsconfig.json | Removed 16 core source path aliases |
packages/vue/tsconfig.build.json | Removed 15 core source path aliases |
packages/vue/package.json | Removed duplicate copyFileSync from build script |
packages/vue/src/components/MarkerTooltip.vue | Relative path → package import |
packages/core/package.json | Added "./engine/marker/registry" export |
package.json (root) | Added build:packages script |
Verification
pnpm --filter @363045841yyt/klinechart-core build # exit 0
pnpm --filter @363045841yyt/klinechart exec vue-tsc --noEmit # exit 0
pnpm --filter @363045841yyt/klinechart build # exit 0
pnpm run build:packages # exit 0Future Work
reactandangularpackages can follow the same pattern once they reach build stage- The root
vite.config.tsandtsconfig.app.jsonstill reference a non-existentsrc/directory (legacy scaffold); consider removing or updating when the monorepo transition is complete - Core exports are ESM-only — if CJS support is needed, add a dual-package build
Cross-framework compatibility
KLineChart needs to run in multiple frontend stacks without forking the chart engine. The current strategy has two layers:
Core exports and source aliases
项目是 pnpm workspace monorepo。@363045841yyt/klinechart-core 是发布包,生产消费者通过 packages/core/package.json 的 exports 使用其公开入口;Vue preview、React preview、Electron renderer…