Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running esbuild under npm explore no longer works #3741

Open
ComLock opened this issue Apr 29, 2024 · 1 comment
Open

Running esbuild under npm explore no longer works #3741

ComLock opened this issue Apr 29, 2024 · 1 comment

Comments

@ComLock
Copy link

ComLock commented Apr 29, 2024

I believe the problem was introduced by the externals change in 0.16.0

Prevent entry files to be marked as externals
#2382

Originally I thought the problem was in tsup:

tsup no longer works with npm explore
egoist/tsup#1110

I think the problem is that when esbuild is run via npm explore, it is run inside a node_modules folder, so it tries to mark all files as external, which means no files inside that folder can be "used", since everything is marked as external.

The error message is:

The entry point "/private/tmp/myproject/node_modules/@enonic/react4xp/tsup.config.client.ts" cannot be marked as external

So I'm assuming tsup is using esbuild to transpile tsup.config.client.ts to tsup.config.client.js, before using it as configuration for the actual build. So tsup has tsup.config.client.ts as an entrypoint, and esbuild complains because it has marked everything under it's parent, parent, parent (node_modules) as external, and an entrypoint can't be an external.

Hmm, perhaps the fix is for tsup to explicitly avoid marking anything as external?

@hyrious
Copy link

hyrious commented Apr 29, 2024

tsup uses bundle-require to load its options, which runs esbuild with a custom resolver plugin that intentionally marks all paths with node_modules as external:

egoist/bundle-require@61f98ee

In fact, there's a similar issue raised in that repo: egoist/bundle-require#42

I believe this is not an issue with esbuild. esbuild do have an option --packages=external but this will not wrongly mark the entry point as external when the entry is in node_modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants