Title: Transpile TypeScript code inside `node_modules`. · Issue #58429 · nodejs/node · GitHub
Open Graph Title: Transpile TypeScript code inside `node_modules`. · Issue #58429 · nodejs/node
X Title: Transpile TypeScript code inside `node_modules`. · Issue #58429 · nodejs/node
Description: What is the problem this feature will solve? I do not propose allowing transforms for all packages in node_modules. That would encourage publishing TypeScript directly to npm, which comes with significant downsides for the ecosystem. Wit...
Open Graph Description: What is the problem this feature will solve? I do not propose allowing transforms for all packages in node_modules. That would encourage publishing TypeScript directly to npm, which comes with sign...
X Description: What is the problem this feature will solve? I do not propose allowing transforms for all packages in node_modules. That would encourage publishing TypeScript directly to npm, which comes with sign...
Opengraph URL: https://github.com/nodejs/node/issues/58429
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Transpile TypeScript code inside `node_modules`.","articleBody":"### What is the problem this feature will solve?\n\n---\n\nI **do not** propose allowing transforms for all packages in `node_modules`. That would encourage publishing TypeScript directly to npm, which comes with significant downsides for the ecosystem.\n\n---\n\nWith the introduction of `--experimental-strip-types` and `--experimental-transform-types`, it is now feasible to run TypeScript code directly without a separate build step.\n\nHowever, in monorepo environments, this feature is limited by how Node.js currently handles `node_modules` resolution. In a typical monorepo setup, you might have a structure like:\n\n```mermaid\ngraph TD\n libA --\u003e server\n libB --\u003e server\n libC --\u003e server\n libD --\u003e libB\n```\n\nTools like `pnpm` (and similarly `yarn` and `npm` workspaces) install local packages via symlinks into the `node_modules` folder. For example, if `server` depends on `libA`, `pnpm` will symlink (or copy, depending on configuration) `libA` into `server/node_modules/libA`.\n\nThe issue is that Node.js currently **does not apply** `--experimental-strip-types` or `--experimental-transform-types` to anything inside a `node_modules` folder, even if it’s a symlink to a local workspace package.\n\nThis forces developers to pre-transpile any local dependencies, which essentially defeats the purpose of the feature in monorepos, where the `server` package often represents only a small percentage of the codebase compared to its locally installed dependencies.\n\nThis might introduce some complexity to the current implementation, since each package could have its own `tsconfig.json` with potentially different options. That said, I’m not deeply familiar with the internals of `--experimental-strip-types` and `--experimental-transform-types`, so this is just an assumption.\n\nBun and Deno come to mind as the major runtimes that support TypeScript out of the box. A study might be needed to determine how to handle `tsconfig` resolution when transpiling packages inside `node_modules`. Should it respect each subpackage's own `tsconfig`? Or should it transpile everything according to the `server`’s `tsconfig`? I’m also unsure what the best or most correct approach would be here.\n\n\u003cbr /\u003e\n\n### What is the feature you are proposing to solve the problem?\n\nI'm still unsure what the best decision would be here, as there are multiple ways to distinguish which folders inside `node_modules` come from local/owned packages and which do not. What about private registries? There's still a lot to decide.\n\n\u003cbr /\u003e\n\n### What alternatives have you considered?\n\nSome options have come to mind:\n\n1. Transpile all packages in `node_modules` that have `\"private\": true`. This ensures those packages did not come from a public registry.\n2. Add a flag like `--transpile-packages=@mycompany/*` to explicitly opt into transforming specific scoped packages.\n3. Automatically transpile all symlinked packages.\n4. Require each package that needs to be transpiled to include a field like `\"source\": \"./src/index.ts\"` or a custom flag such as `\"needsTranspilation\": true`.\n\nA flag like the latter would be especially useful, as it would enable users to publish TypeScript packages to private or internal registries while still opting into transformation behavior.\n\nSince this restriction was intentionally designed to prevent publishing uncompiled TypeScript to npm, perhaps a more consistent approach would be to **only** block transpilation for packages that clearly come from the public registry. Again, there's a lot to discuss here...\n","author":{"url":"https://github.com/arthurfiorette","@type":"Person","name":"arthurfiorette"},"datePublished":"2025-05-23T01:11:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":67},"url":"https://github.com/58429/node/issues/58429"}
| 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:73251a13-7494-5fc5-6170-1fce0309a5b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC5C:232EF3:11ACB87:18352D7:6A4D6ACB |
| html-safe-nonce | 566ff6ccb0c6b542ce547e7f98c9f8a486936a5375a44383315931d020664071 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzVDOjIzMkVGMzoxMUFDQjg3OjE4MzUyRDc6NkE0RDZBQ0IiLCJ2aXNpdG9yX2lkIjoiOTEwMzQ4NTQzNTM4ODk3OTkxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eade17c686b5837736ee6268a470a322f9c7c6707d66b6e952fabae787791ba5 |
| hovercard-subject-tag | issue:3084881636 |
| 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/nodejs/node/58429/issue_layout |
| twitter:image | https://opengraph.githubassets.com/587a180249aae98885416f20f0e48092e740aa38f7879337f97ebaec16c31dc4/nodejs/node/issues/58429 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/587a180249aae98885416f20f0e48092e740aa38f7879337f97ebaec16c31dc4/nodejs/node/issues/58429 |
| og:image:alt | What is the problem this feature will solve? I do not propose allowing transforms for all packages in node_modules. That would encourage publishing TypeScript directly to npm, which comes with sign... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arthurfiorette |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7db3950e3f59095e20a9789440c3dd554efc62d434882ead06ae05b5815605b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| 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 | cd8f6a71db61d6012a0cbb134be844fdbe9b8a45 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width