Hacker News new | ask | show | jobs
by MrJohz 57 days ago
> - packages in workspaces can be used as dependencies without compilation (node's type stripping doesn't support this)

Node does support this! Although it may depend on exactly you link the packages within a workspace — I use `pnpm` and it Just Works™. Because NodeJS looks at the resolved symlink to decide whether a project is in `node_modules` or not, if the symlink resolves to a package in the workspace, then NodeJS will do type stripping as normal.

In fairness, the documentation is very unspecific about this, so I just had to try it out and see what happens, but it does work.

I think NodeJS also has coverage these days, although I could be wrong there.

1 comments

That must be new. It did not work when I last tested type stripping, earlier this year using pnpm as well. And to be fair bun didn't work either.

Glad if it's working now regardless though, I also see some experimental support for coverage in the docs now.

That could well be the case, I think I switched our monorepo over to as-node-native-as-possible at some point this year, possible after April or so. But I don't have the codebase at hand unfortunately, so I can't be more exact.

I do wish some of this stuff would be documented better. I find Node's documentation to be some of the worst for never being able to answer the specific question I have when I'm reading it — IIRC I was also unsure whether the type stripping thing would work for a monorepo, and the closest confirmation I could find online was a comment in a PR somewhere that implied it ought to work, but nothing more specific.