Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type augmentation and compiler-sfc types w/moduleResolution: bundler (fix #13106) #13107

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"import": {
"node": "./dist/vue.runtime.mjs",
"default": "./dist/vue.runtime.esm.js"
},
"require": "./dist/vue.runtime.common.js",
"types": "./types/index.d.ts"
"require": "./dist/vue.runtime.common.js"
},
"./compiler-sfc": {
"types": "./compiler-sfc/index.d.ts",
"import": "./compiler-sfc/index.mjs",
"require": "./compiler-sfc/index.js"
},
"./dist/*": "./dist/*",
"./types/*": "./types/*",
"./types/*": ["./types/*.d.ts", "./types/*"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To help clarify the conversion from import name to file lookups, I tried to follow the pseudo-code from the documentation here and list out what would happen in the following scenarios:

Before this change:

"vue/types/options" => ["./types/options"] // fails to find types
"vue/types/options.js" => ["./types/options.ts", "./types/options.d.ts", "./types/options.js"] // finds on second try
"vue/types/options.d.ts" => ["./types/options.d.ts"] // finds on first try

After this change:

"vue/types/options" => ["./types/options.d.ts", "./types/options"] // finds on first try
"vue/types/options.js" => ["./types/options.js.d.ts", "./types/options.ts", "./types/options.d.ts", "./types/options.js"] // finds on third try
"vue/types/options.d.ts" => ["./types/options.d.ts.d.ts", "./types/options.d.ts"] // finds on second try

Since the most common case is to write these imports without the extensions, I thought it would be best to write this as ["./types/*.d.ts", "./types/*"]. This makes the common case more direct to resolve, at the expense of a few more non-sensical checks (.d.ts.d.ts and .js.d.ts) in the uncommon case where we were importing with an extension.

"./package.json": "./package.json"
},
"sideEffects": false,
Expand Down