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

tsup no longer works with npm explore #1110

Open ComLock opened 2 months ago

ComLock commented 2 months ago

This https://github.com/enonic/starter-react4xp/blob/16a350485827d80be28aea384c3367d251edac5b/package.json#L94

Runs this: https://github.com/enonic/npm-react4xp/blob/5911b76ea605c5595148390f6054dc11b781969c/package.json#L114

Which finally runs this: https://github.com/enonic/npm-react4xp/blob/5911b76ea605c5595148390f6054dc11b781969c/package.json#L127

Which is:

npx tsup --config tsup.config.client.ts

Which will give this error:

npx tsup --config tsup.config.client.ts
✘ [ERROR] The entry point "/private/tmp/myproject/node_modules/@enonic/react4xp/tsup.config.client.ts" cannot be marked as external

Error: Build failed with 1 error:
error: The entry point "/private/tmp/myproject/node_modules/@enonic/react4xp/tsup.config.client.ts" cannot be marked as external
    at failureErrorWithLog (/private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:1651:15)
    at /private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:1059:25
    at runOnEndCallbacks (/private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:1486:45)
    at buildResponseToResult (/private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:1057:7)
    at /private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:1086:16
    at responseCallbacks.<computed> (/private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/private/tmp/myproject/node_modules/@enonic/react4xp/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)

Editing tsup.config.client.ts changes nothing, it seem's it doesn't even attempt to read the file.

If I rename /private/tmp/myproject/node_modules to /private/tmp/myproject/whatever

Then cd /private/tmp/myproject/whatever/@enonic/react4xp/ I can run npm install And now npx tsup --config tsup.config.client.ts works.

So it seems to mark everything under "node_modules" as external?

Upvote & Fund

Fund with Polar

ComLock commented 2 months ago

Might be related to https://github.com/evanw/esbuild/issues/2382

ComLock commented 2 months ago

Hmm, even downgrading to tsup 6.7.0 and esbuild 0.17.9 didn't help. Perhaps it's another module.

ComLock commented 2 months ago

The externals change came in https://github.com/evanw/esbuild/releases/tag/v0.16.0, but even downgrading to 0.15.8 didn't help.

ComLock commented 2 months ago

Ah, tsup had it's own copy of esbuild under node_modules/tsup/node_modules/esbuild.

I had to downgrade to tsup 6.5.0 so an old enough version of esbuild was used (0.15.8) then it worked.

So I guess the problem is in esbuild from version 0.16.0.

I guess this ticket should be moved to esbuild then?

ComLock commented 2 months ago

https://github.com/egoist/bundle-require/issues/42