You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The esbuild-node-externals plugin allows you to specify an allowList parameter for including dependencies into the bundle.
Why would you want this? For example:
A project (typically a monorepo) that uses internal dependencies of type "foo": "link:.src/some/path/foo" in the package.json. These aren't really external dependencies and they should be bundled/transpiled, they're just a convenient way to make bits of the source appear as top-level packages for import.
Creating single-file deployments, where the entire node_modules is intentionally bundled. It's possible and convenient if you have no native binary dependencies.
Bundling only selected (perhaps vendored) node_modules packages.
In our case, the first bullet prevents us from using esbuild-runner for some of our tools: our source tree is pure ESM, esr transpiles to CJS for running under node except the internally linked entries defined in packages.json aren't being bundled, so the result doesn't run.
I would like to suggest one or two options:
Add an esr config option allowList or externalsAllowList, specifying dependencies that should be transpiled/bundled.
Add an esr config option to disable the default externalizing of node_modules entirely. Then I could presumably add the esbuild-node-externals plugin myself to the config, or write my own plugin like in the esbuild docs, which supports fine-grained control of which dependencies to include or exclude.
If this is something you'd consider, I could try to make a PR.
The text was updated successfully, but these errors were encountered:
I had the same problem when upgrading from node-fetch 2.x (non ESM) to node-fetch 3.x (ESM). It's quite surprisingly that esbuild-runner automatically externalize direct dependencies in package.json which is not the behavior of esbuild.
Moreover the behavior is not the same for indirect dependencies which are not externalized. So the final behavior is quite strange, and i was forced to patch esbuild-runner to be able to fully control the external parameter.
I would suggest to remove the reading of package.json so that we can have full control on the external list, and be able to use other alternative like @tjunnone is suggesting
The esbuild-node-externals plugin allows you to specify an
allowList
parameter for including dependencies into the bundle.Why would you want this? For example:
"foo": "link:.src/some/path/foo"
in the package.json. These aren't really external dependencies and they should be bundled/transpiled, they're just a convenient way to make bits of the source appear as top-level packages forimport
.In our case, the first bullet prevents us from using esbuild-runner for some of our tools: our source tree is pure ESM, esr transpiles to CJS for running under node except the internally linked entries defined in packages.json aren't being bundled, so the result doesn't run.
I would like to suggest one or two options:
allowList
orexternalsAllowList
, specifying dependencies that should be transpiled/bundled.If this is something you'd consider, I could try to make a PR.
The text was updated successfully, but these errors were encountered: