fix: publish the type declarations and fix the ESM export path - #968
Merged
Merged
Conversation
Since the TypeScript conversion in chartjs#907 the package has shipped no types at all, and could not be imported from ESM. Both are still unreleased: v2.2.0 predates that commit. "types" pointed at dist/index.d.ts, but `tsc --emitDeclarationOnly` writes to dist/src/, because rootDir has to stay at the repo root for src/plugin.ts to import the version out of package.json. The "dist/*.d.ts" entry in "files" does not match a subdirectory, so nothing was packed. Point both at dist/src/ instead. "exports.import" asked for dist/chartjs-plugin-zoom-esm.js. Rollup writes chartjs-plugin-zoom.esm.js, so `import 'chartjs-plugin-zoom'` failed with ERR_MODULE_NOT_FOUND. The specs live beside the sources, so declaration emit moves to tsconfig.build.json, which excludes them; tsconfig.json still includes them and `npm run typecheck` keeps covering them. Verified by installing the packed tarball into a throwaway project: `tsc` resolves the types and `import()` returns the plugin, both of which fail with the tarball built from master. This publishes the module layout as tsc emits it, so core, gestures, handlers, state and the rest land in the tarball as separate declarations. A follow-up rolls them into a single dist/index.d.ts; keeping that separate leaves this commit to the two outright bugs. `require('chartjs-plugin-zoom')` still returns {} either way, because "type": "module" makes node read the UMD bundle as ESM. That needs a separate CJS output and is left alone here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the TypeScript conversion in #907 the package has shipped no types at all, and could not be imported from ESM. Both are still unreleased: v2.2.0 predates that commit.
"types" pointed at dist/index.d.ts, but
tsc --emitDeclarationOnlywrites to dist/src/, because rootDir has to stay at the repo root for src/plugin.ts to import the version out of package.json. The "dist/*.d.ts" entry in "files" does not match a subdirectory, so nothing was packed. Point both at dist/src/ instead."exports.import" asked for dist/chartjs-plugin-zoom-esm.js. Rollup writes chartjs-plugin-zoom.esm.js, so
import 'chartjs-plugin-zoom'failed with ERR_MODULE_NOT_FOUND.The specs live beside the sources, so declaration emit moves to tsconfig.build.json, which excludes them; tsconfig.json still includes them and
npm run typecheckkeeps covering them.Verified by installing the packed tarball into a throwaway project:
tscresolves the types andimport()returns the plugin, both of which fail with the tarball built from master.This publishes the module layout as tsc emits it, so core, gestures, handlers, state and the rest land in the tarball as separate declarations. A follow-up rolls them into a single dist/index.d.ts; keeping that separate leaves this commit to the two outright bugs.
require('chartjs-plugin-zoom')still returns {} either way, because "type": "module" makes node read the UMD bundle as ESM. That needs a separate CJS output and is left alone here.