Title: Surprising (or incorrect) priorities with package.json exports fields? · Issue #46334 · microsoft/TypeScript · GitHub
Open Graph Title: Surprising (or incorrect) priorities with package.json exports fields? · Issue #46334 · microsoft/TypeScript
X Title: Surprising (or incorrect) priorities with package.json exports fields? · Issue #46334 · microsoft/TypeScript
Description: I'm trying a scenario of module: nodenext with Vue.js. I hit a few issues with resolution of declaration files. Here's the current Vue.js declarations package.json: { "name": "vue", "version": "3.2.20", "description": "The progressive Ja...
Open Graph Description: I'm trying a scenario of module: nodenext with Vue.js. I hit a few issues with resolution of declaration files. Here's the current Vue.js declarations package.json: { "name": "vue", "version": "3.2...
X Description: I'm trying a scenario of module: nodenext with Vue.js. I hit a few issues with resolution of declaration files. Here's the current Vue.js declarations package.json: { "name": &quo...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/46334
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Surprising (or incorrect) priorities with package.json exports fields?","articleBody":"I'm trying a scenario of `module: nodenext` with Vue.js. I hit a few issues with resolution of declaration files.\r\n\r\nHere's the current Vue.js declarations `package.json`:\r\n\r\n ```json5\r\n {\r\n \"name\": \"vue\",\r\n \"version\": \"3.2.20\",\r\n \"description\": \"The progressive JavaScript framework for buiding modern web UI.\",\r\n \"main\": \"index.js\",\r\n \"module\": \"dist/vue.runtime.esm-bundler.js\",\r\n \"types\": \"dist/vue.d.ts\",\r\n // ...\r\n \"exports\": {\r\n \".\": {\r\n \"import\": {\r\n \"node\": \"./index.mjs\",\r\n \"default\": \"./dist/vue.runtime.esm-bundler.js\"\r\n },\r\n \"require\": \"./index.js\"\r\n },\r\n // ...\r\n \"./package.json\": \"./package.json\"\r\n }\r\n // ...\r\n }\r\n ```\r\n\r\nHowever, referencing this in a project results in the following error:\r\n\r\n```ts\r\nimport * as Vue from \"vue\";\r\n// ~~~~~\r\n// error\r\n// Could not find a declaration file for module 'vue'. 'USER_DIR/hackathon/vue-proj/node_modules/vue/index.js' implicitly has an 'any' type.\r\n// Try `npm i --save-dev @types/vue` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue';`\r\n```\r\n\r\nThis kind of makes sense - I think you could argue that this isn't configured right for `moduleResolution: node12` or later.\r\n\r\nI was able to get this working by adding \r\n\r\n```diff\r\n \"exports\": {\r\n \".\": {\r\n \"import\": {\r\n \"node\": \"./index.mjs\",\r\n \"default\": \"./dist/vue.runtime.esm-bundler.js\"\r\n },\r\n \"require\": \"./index.js\",\r\n+ \"types\": \"./dist/vue.d.ts\"\r\n },\r\n }\r\n```\r\n\r\nBut the following DID NOT work.\r\n\r\n ```diff\r\n \"exports\": {\r\n \".\": {\r\n \"import\": {\r\n \"node\": \"./index.mjs\",\r\n \"default\": \"./dist/vue.runtime.esm-bundler.js\"\r\n + \"types\": \"./dist/vue.d.ts\"\r\n },\r\n \"require\": \"./index.js\",\r\n },\r\n }\r\n ```\r\n\r\nThat part seems like a bug, right?\r\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2021-10-13T00:43:55Z","url":"https://github.com/microsoft/TypeScript/issues/46334"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e44f1da0-0899-8171-89c9-c95bbda7b13f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5E0:31E99C:BF9235:1016FF8:6B00F850 |
| html-safe-nonce | a422e7ca7a3ef188c377737895b8065afaa209ab2934e85b54770eadc919a819 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUUwOjMxRTk5QzpCRjkyMzU6MTAxNkZGODo2QjAwRjg1MCIsInZpc2l0b3JfaWQiOiIyOTQ0ODY3NDAwODYxOTM5NzkyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6f97df1eb50f9160ed6afeaa4e5e1cf702241457cc5f9fcecda06bcaa338ef1a |
| hovercard-subject-tag | issue:1024644268 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/46334/issue_layout |
| twitter:image | https://opengraph.githubassets.com/59bb762af50390877544908f15da6f1b82d640f6a7b86a5129e7e31b1c58090b/microsoft/TypeScript/issues/46334 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/59bb762af50390877544908f15da6f1b82d640f6a7b86a5129e7e31b1c58090b/microsoft/TypeScript/issues/46334 |
| og:image:alt | I'm trying a scenario of module: nodenext with Vue.js. I hit a few issues with resolution of declaration files. Here's the current Vue.js declarations package.json: { "name": "vue", "version": "3.2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width