Skip to content

finding(plugin-charts): two deep subpaths resolve only through the repo vitest alias — the #4325 shape again, and this one has a value import #4529

Description

@yinlianghui

Observation-class finding, surfaced while wiring @object-ui/plugin-dashboard's tests into tsc for #4040 (closing tranche). Nothing a user meets today — both live consumers are tests, and they pass.

This is the same class as #4325 (@object-ui/fields deep subpaths), one package over. It is filed separately rather than as a comment there because #4325 is closed, and because the resolution that closed it does not transfer cleanly — see "Why the #4325 remedy does not just apply" below.

What

packages/plugin-charts/package.json publishes exactly one entry point:

"exports": {
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.umd.cjs" }
}

Two plugin-dashboard tests import subpaths of it:

packages/plugin-dashboard/src/__tests__/DatasetWidget.chartConfig.dom.test.tsx:38
    import '@object-ui/plugin-charts/AdvancedChartImpl';
packages/plugin-dashboard/src/__tests__/DatasetWidget.comboPresentation.test.tsx:52
    import { normalizeChartSchema } from '@object-ui/plugin-charts/normalizeChartSchema';

Both resolve only because vitest.config.mts:262 aliases the whole package name to its source directory:

'@object-ui/plugin-charts': path.resolve(__dirname, './packages/plugin-charts/src')

Neither name is exported from the barrel either — packages/plugin-charts/src/index.tsx exports ChartBarRenderer, ChartRenderer, ObjectChart, ObjectChartBlock, chartComponents and the BarChartSchema type, and nothing else. Under Node's own resolution, or from any consumer outside this repo's vitest config, both specifiers are ERR_PACKAGE_PATH_NOT_EXPORTED.

How it surfaced

Type-checking plugin-dashboard's tests puts both files in front of tsc, which asks the same question Node would:

src/__tests__/DatasetWidget.chartConfig.dom.test.tsx(38,8): error TS2882: Cannot find module or type declarations for side-effect import of '@object-ui/plugin-charts/AdvancedChartImpl'.
src/__tests__/DatasetWidget.comboPresentation.test.tsx(52,38): error TS2307: Cannot find module '@object-ui/plugin-charts/normalizeChartSchema' or its corresponding type declarations.

These were 2 of the 14 errors that package's tests carried.

Why the #4325 remedy does not just apply

#4325 was closed by PR #4460, "drop the unpublished deep subpath" — the test's anti-race guarantee was rebuilt on a witness that did not need it. That answer fits the FIRST import here and not the second:

What the #4040 PR did, and why it is not the answer

PR for #4040's closing tranche keeps both imports and restates the vitest alias as one narrow paths entry in the new packages/plugin-dashboard/tsconfig.test.json:

"paths": { "@object-ui/plugin-charts/*": ["packages/plugin-charts/src/*"] }

That points tsc at the very files vitest loads, so the compiler checks the real modules rather than a hand-written shim, and no test semantics changed. It is commented in that file as a workaround for this gap, with the instruction to delete it once the gap is closed either way. It is worth recording precisely because that config now carries a source-tree path every other wired-up package avoided on purpose — the same debt #4325 recorded, with the same wording, before its ruling removed it.

Why it is finding and not queued

No user-visible behaviour depends on it, and the fix is a product call about what @object-ui/plugin-charts publishes, not a code one:

  • The subpaths are intended — a renderer's normalization layer is a reasonable thing to test against directly. Then plugin-charts should publish them in its exports map with the matching dist layout, and the paths entry goes away.
  • They are not intended — the package's surface is its index. Then normalizeChartSchema needs to be re-exported from the barrel (a one-line surface decision) or the test needs a different witness, and the lazy-chunk pre-load needs test(plugin-detail): drop the unpublished @object-ui/fields deep subpath (#4325) #4460's treatment.

Note the second bullet is not symmetrical with #4325: there, "not intended" meant the import could simply go. Here it still requires a decision about normalizeChartSchema's reachability, because the test cannot make its assertion without the real translation layer.

A general question worth asking once instead of per-package: this is the second instance in two tranches, and the vitest alias makes the mistake invisible until a package's tests reach tsc. Now that #4040 has every package type-checking its tests, a gate over exports maps versus the deep specifiers actually imported would catch the third one at authoring time.

Refs #4325, #4460, #4040.


Generated by Claude Code

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions