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

Configuration option external is ignored #23

Closed
vieira opened this issue May 31, 2021 · 2 comments
Closed

Configuration option external is ignored #23

vieira opened this issue May 31, 2021 · 2 comments

Comments

@vieira
Copy link

vieira commented May 31, 2021

Hello,

I tried defining pg-native as an external dependency but it seems the option is ignored, i.e., not being merged with the computed externals here:

external: externals,

My esbuild-runner.config.js:

module.exports = {
  type: 'bundle',
  esbuild: {
    external: ['pg-native'],
  },
}

and the error that is produced when running:

 > ../../node_modules/pg/lib/native/client.js:4:21: error: Could not resolve "pg-native" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
    4 │ var Native = require('pg-native')
      ╵                      ~~~~~~~~~~~


/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1466
  let error = new Error(`${text}${summary}`);
              ^
Error: Build failed with 1 error:
../../node_modules/pg/lib/native/client.js:4:21: error: Could not resolve "pg-native" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
    at failureErrorWithLog (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1466:15)
    at /Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1148:28
    at runOnEndCallbacks (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1066:65)
    at buildResponseToResult (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1146:7)
    at /Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1253:14
    at /Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:726:9)
    at readFromStdout (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:596:7)
    at runServiceSync (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1831:3)
    at Object.buildSync (/Users/vieira/Code/f1/node_modules/esbuild/lib/main.js:1651:3)

I should note that I am using npm7 workspaces and that pg-native is a dependency of a dependency of another package in the workspace, if I add the dependency directly to the package.json of the package I am trying to run it works (the externals computation finds it).

@folke
Copy link
Owner

folke commented Jun 1, 2021

The reason is that we take all deps and devdeps from your package.json and put those as externals. I'll change it so you can additionally pass in any other externals as you do right now.

@folke
Copy link
Owner

folke commented Jun 1, 2021

I just released a new version where your external config should now work as expected. Thank you for reporting!

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