Skip to content

Support node type stripping in pnpm deploy #10602

Closed
Closed

Description

@everett1992

Contribution

Describe the user story

node.js supports running a subset of typescript natively, but for reasons they don't allow this feature for files in node_modules.

A caveat is that node wants to support npm workspaces, where local sub packages are required thru node_modules.
To do so they check the real path of the file, and will type strip it if it's not within node_modules.

This works in pnpm workspaces, but breaks in pnpm deploy. This repo demonstrates that behavior.

Read or run repro.sh steps to reproduce.

This difference between workspace and deploy structure

bin/node_modules/lib -> ../../lib
out/node_modules/lib -> .pnpm/lib@file++++lib/node_modules/lib

cause this error in out/index.ts, but not bin/index.ts

Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]: Stripping types is currently unsupported for files under node_modules, for "file:///out/node_modules/.pnpm/lib@file++++lib/node_modules/lib/index.ts"

https://github.com/everett1992/pnpm-node-type-stripping

Describe the solution you'd like

It's not clear if this is a pnpm problem or a node problem. It's at the intersection of both. For what it's worth I think node's wrong to forbid type stripping in node_modules, but I'm willing to accept the constraint to avoid dependencies on amaro, tsx, ts-node ect.

Node's dogma is probably that I should compile before deployment, but

  • I want all my dev tools to use typescript source, and getting conditional exports right is hard
  • source maps :sad: - tho if tsc supported strip-types I'd live without source maps
  • I don't care about the startup perf

I think pnpm could solve this by linking the workspace modules to a location other than <store>/*/node_modules/, tho I think that node_modules is important (but how is the workspace working 🤔 )

node could solve this by removing the constraint, or introducing new markers for "this is in node_modules but I promise I didn't publishing it to npm"

Describe the drawbacks of your solution

For pnpm this solution feels like bending over backward to odd runtime constraints.

Describe alternatives you've considered

My workaround for now is to use --import=amaro/strip. amaro is the lib that implements node type stripping. I could also switch to bun or deno.

Activity

  1. yegorpetrov commented on May 7, 2026

    @yegorpetrov

    they check the real path of the file

    if this is a pnpm problem or a node problem

    It's 100% a node problem. pnpm deploy isn't the only legitimate use case. For example, symlinks are not easy (if at all possible) to preserve when you're supposed to zip node modules for deployment and don't have control over the target file system.

    Package your layer content. This means creating a .zip file archive that contains the dependencies you want to use in your functions.

    And when l have this among dependencies...

    "my-pkg": "file:local-packages/my-pkg"
    

    ... I can't make my-pkg pure TypeScript even though it's not going to be published.

  2. damianobarbati commented on May 20, 2026

    @damianobarbati

    @everett1992 did you find a solution? This is a nodejs problem, and the dumb decision to not strip files in node_modules, forcing authors to always transpile here and there

  3. locked and limited conversation to collaborators on Sep 26, 2026
  4. converted this issue into a discussion #15821 on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions