Skip to content

feat: add exports to package.json and expose eslint-plugin-vue/types - #3252

Open
ValentinYoushkevich wants to merge 9 commits into
vuejs:masterfrom
ValentinYoushkevich:feat/package-exports
Open

ValentinYoushkevich wants to merge 9 commits into
vuejs:masterfrom
ValentinYoushkevich:feat/package-exports

Conversation

@ValentinYoushkevich

@ValentinYoushkevich ValentinYoushkevich commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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 main fallback while exports pointed at the missing dist/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's eslint-plugin-vue/dist/eslint-typegen stop resolving. Extensionless dist/* paths now map to .js files, every dist directory with an index.js maps to it, typesVersions covers moduleResolution: node, and a new test checks all of this.

ValentinYoushkevich and others added 5 commits November 12, 2026 13:21
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-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7276104

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-vue Minor

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

@FloEdelmann

Copy link
Copy Markdown
Member

Blocked by #3250 (which this PR builds upon).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 dist paths.
  • Adds a typesVersions fallback 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

Comment thread package.json Resolved

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the Copilot comment above as well.

Comment thread .changeset/twelve-weeks-rhyme.md Resolved
Comment thread tests/lib/package-exports.test.ts Outdated
Comment on lines +34 to +35
.map((file) => `dist/${String(file).replaceAll('\\', '/')}`)
.filter((file) => path.posix.basename(file) === 'index.js')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why replace \ with / and then use .posix instead of just relying on path.basename itself?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the generated types in a stable way

4 participants