Repository navigation
feat: add exports to package.json and expose eslint-plugin-vue/types - #3252
ValentinYoushkevich wants to merge 9 commits into
Conversation
Adding an exports field to the package.json. For compatibility with the existing 10.7.0 artifacts (where someone might be importing from `eslint-plugin-vue/dist/*`, we are also exposing those files through a wildcard export. In a future major release, the wildcard will likely be dropped.
Before `exports`, `require('eslint-plugin-vue/dist/utils')` and other
extensionless `dist/*` paths resolved through Node's file lookup, and
TypeScript resolved `eslint-plugin-vue/dist/eslint-typegen` the same way.
Export maps do no such lookup, so map extensionless `dist/*` paths to
`.js` files (TypeScript then finds the `.d.ts` next to them) and map the
`dist/utils` directory to its index file.
TypeScript ignores `exports` with `moduleResolution: node`/`node10`, which is still the default for `module: commonjs` in TypeScript 5. Map the subpath in `typesVersions` so `eslint-plugin-vue/types` works there too.
🦋 Changeset detectedLatest commit: 7276104 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Blocked by #3250 (which this PR builds upon). |
There was a problem hiding this comment.
🟡 Changes recommended
Package exports break four existing import paths by targeting nonexistent files or leaving them unexported, so explicit index aliases and resolution tests are needed.
1 open issue
What changed in this PR
Provides a stable eslint-plugin-vue/types entry point for generated lint-rule types and defines explicit exports for the plugin package.
Changes:
- Adds exports for the plugin, generated types, and existing
distpaths. - Adds a
typesVersionsfallback for legacy TypeScript resolution. - Adds package-resolution tests and a minor-release changeset.
| File | Description |
|---|---|
tests/lib/package-exports.test.ts |
Tests runtime exports and modern TypeScript resolution. |
package.json |
Defines package exports and legacy type-resolution mappings. |
.changeset/twelve-weeks-rhyme.md |
Documents the new type export for a minor release. |
Review effort: Max
FloEdelmann
left a comment
There was a problem hiding this comment.
Please see the Copilot comment above as well.
| .map((file) => `dist/${String(file).replaceAll('\\', '/')}`) | ||
| .filter((file) => path.posix.basename(file) === 'index.js') |
There was a problem hiding this comment.
Why replace \ with / and then use .posix instead of just relying on path.basename itself?
There was a problem hiding this comment.
The conversion is only needed for the specifier: require.resolve() wants /, while readdirSync() returns \ on Windows. Simplified it so the filter uses path.basename() and only the specifier is converted.

Fixes #3010. This continues #3013 by @thebanjomatic and keeps their commit, with Flo's changeset wording on top. The integration failure was only the test setup: CI then unpacked the dist artifact into the repo root, so master passed through Node's legacy
mainfallback whileexportspointed at the missingdist/index.js, fixed since by #3002. The original map would still break real users, because export maps skip extension and directory lookup:require('eslint-plugin-vue/dist/utils')(used by rancher and shopware) and TypeScript'seslint-plugin-vue/dist/eslint-typegenstop resolving. Extensionlessdist/*paths now map to.jsfiles, everydistdirectory with anindex.jsmaps to it,typesVersionscoversmoduleResolution: node, and a new test checks all of this.