Title: Types are not portable error when trying to generate .d.ts files with unplugin packages · Issue #322 · unjs/unplugin · GitHub
Open Graph Title: Types are not portable error when trying to generate .d.ts files with unplugin packages · Issue #322 · unjs/unplugin
X Title: Types are not portable error when trying to generate .d.ts files with unplugin packages · Issue #322 · unjs/unplugin
Description: Environment node 18.12.1 pnpm 8.6.5 typescript 5.1.6 unplugin 1.3.2 Reproduction https://github.com/evmts/evmts-monorepo/blob/main/bundlers/bundler/src/unplugin/index.ts Check out monorepo pnpm install cd bundlers/bundler npx tsc --emitD...
Open Graph Description: Environment node 18.12.1 pnpm 8.6.5 typescript 5.1.6 unplugin 1.3.2 Reproduction https://github.com/evmts/evmts-monorepo/blob/main/bundlers/bundler/src/unplugin/index.ts Check out monorepo pnpm ins...
X Description: Environment node 18.12.1 pnpm 8.6.5 typescript 5.1.6 unplugin 1.3.2 Reproduction https://github.com/evmts/evmts-monorepo/blob/main/bundlers/bundler/src/unplugin/index.ts Check out monorepo pnpm ins...
Opengraph URL: https://github.com/unjs/unplugin/issues/322
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Types are not portable error when trying to generate .d.ts files with unplugin packages","articleBody":"### Environment\n\n- node 18.12.1\r\n- pnpm 8.6.5\r\n- typescript 5.1.6\r\n- unplugin 1.3.2\n\n### Reproduction\n\nhttps://github.com/evmts/evmts-monorepo/blob/main/bundlers/bundler/src/unplugin/index.ts\r\n\r\n1. Check out monorepo\r\n2. `pnpm install`\r\n3. `cd bundlers/bundler`\r\n4. `npx tsc --emitDeclarationOnly`\n\n### Describe the bug\n\nWhen trying to compile unplugin we get a `type is not portable` error on multiple plugins.\n\n### Additional context\n\nThis error happens when trying to compile a `.d.ts` file. Some inferred type within unplugin is private, making it impossible for the `.d.ts` file to reference it. Because of this this error gets thrown.\r\n\r\nAs a workaround I cast the `vite` plugin as a `rollup` plugin and the `webpack` plugin as a `rsPack` plugin.\r\n\r\nTo fix just need to explicitly type whatever types from vite and webpack are being inferred privately or reexport them.\n\n### Logs\n\n```sh\nsrc/unplugin/index.ts:55:14 - error TS2742: The inferred type of 'viteFoundry' cannot be named without a reference to '.pnpm/vite@4.3.9_@types+node@20.4.2/node_modules/vite'. This is likely not portable. A type annotation is necessary.\r\n\r\n55 export const viteFoundry = foundryUnplugin.vite\r\n ~~~~~~~~~~~\r\n\r\nsrc/unplugin/index.ts:58:14 - error TS2742: The inferred type of 'webpackFoundry' cannot be named without a reference to '.pnpm/webpack@5.1.0/node_modules/webpack'. This is likely not portable. A type annotation is necessary.\r\n\r\n58 export const webpackFoundry =\r\n```\n```\n","author":{"url":"https://github.com/roninjin10","@type":"Person","name":"roninjin10"},"datePublished":"2023-07-15T18:08:06Z","url":"https://github.com/unjs/unplugin/issues/322"}
| 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:51d5992b-b7ac-cbca-f9c8-1b1b2c26bf62 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8830:3388:23F4E7:325B81:6B0058D7 |
| html-safe-nonce | 27bc69a52306b86ee2dedfc411833d225f498fef811991254bf40cf862a0617d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODMwOjMzODg6MjNGNEU3OjMyNUI4MTo2QjAwNThENyIsInZpc2l0b3JfaWQiOiIxMDgxMTQ0NDU5NjI3ODc4NjE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2f45b98cf07a53608f6f1720e7363b6a51258a11f73c10e6f5a59965af6057ad |
| hovercard-subject-tag | issue:1806261353 |
| 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/unjs/unplugin/322/issue_layout |
| twitter:image | https://opengraph.githubassets.com/770e1ec8884d88a2d93d98ff1c684ea473dcc2709c1f1d492b82a38edee5e346/unjs/unplugin/issues/322 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/770e1ec8884d88a2d93d98ff1c684ea473dcc2709c1f1d492b82a38edee5e346/unjs/unplugin/issues/322 |
| og:image:alt | Environment node 18.12.1 pnpm 8.6.5 typescript 5.1.6 unplugin 1.3.2 Reproduction https://github.com/evmts/evmts-monorepo/blob/main/bundlers/bundler/src/unplugin/index.ts Check out monorepo pnpm ins... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | roninjin10 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73 |
| turbo-cache-control | no-preview |
| go-import | github.com/unjs/unplugin git https://github.com/unjs/unplugin.git |
| octolytics-dimension-user_id | 80154025 |
| octolytics-dimension-user_login | unjs |
| octolytics-dimension-repository_id | 385261169 |
| octolytics-dimension-repository_nwo | unjs/unplugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 385261169 |
| octolytics-dimension-repository_network_root_nwo | unjs/unplugin |
| 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 | eacd927ba6112e3b01ba99c762bd699a4a4f5df7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width