zip-it-and-ship-it icon indicating copy to clipboard operation
zip-it-and-ship-it copied to clipboard

[esbuild] Wrong version of external module selected when multiple exist

Open eduardoboucas opened this issue 3 years ago • 0 comments

- Do you want to request a feature or report a bug?

🐞

- What is the current behavior?

When a module is flagged as external, the following happens:

  1. the require will be left untouched by esbuild (e.g. require('foobar'))
  2. zip-it-and-ship-it will try to find the module _from the root _directory — if it exists at node_modules/foobar, that directory will be included in the zipped artefact
  3. when the function runs, require('foobar') will resolve to the directory created in 2

This can break if multiple versions of foobar exist and a transitive dependency requires one that is different from the version at the root level — e.g. we'll bundle node_modules/foobar instead of node_modules/some-other-module/node_modules/foobar.

- If the current behavior is a bug, please provide the steps to reproduce.

  • Create a project with the module structure described above
  • Verify that the wrong version of the external module is included in the zip

- What is the expected behavior?

Described above.

- Please mention your node.js, and operating system version.

N/A

eduardoboucas avatar Mar 15 '21 16:03 eduardoboucas