egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.46k stars 209 forks source link

RollupError: "Writable" is not exported by "node:stream", imported by "src/foo.ts". #1095

Open moltar opened 3 months ago

moltar commented 3 months ago

A really strange error...

src/foo.ts imports from Node internal:

import type { Writable } from 'node:stream'

tsup config:

{
  "clean": true,
  "sourcemap": true,
  "watch": false,
  "silent": true,
  "entry": [
    "src/index.ts"
  ],
  "dts": {
    "resolve": true
  },
  "tsconfig": "tsconfig.build.json",
  "outDir": "lib",
  "format": [
    "cjs",
    "esm"
  ],
  "shims": true,
  "target": "node18.19.1"
}

Marking the node:stream package as external fixes the problem.

  "external": [
    "node:stream"
  ],

Am I doing something wrong?

I have never had to add externals to the list in any other packages before.

Upvote & Fund

Fund with Polar