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

error: Could not resolve "simple-exiftool" #423

Closed
alexkli opened this issue Oct 3, 2020 · 3 comments
Closed

error: Could not resolve "simple-exiftool" #423

alexkli opened this issue Oct 3, 2020 · 3 comments

Comments

@alexkli
Copy link

alexkli commented Oct 3, 2020

(First of all, awesome tool, great speed!)

Problem

I tried esbuild for our node applications, and it generally works. However, there seems to be an issue with simple-exiftool - as soon as it is required, it fails with the error:

../../../../../../../nui/esbuild-test/project/index.js:1:8: error: Could not resolve "simple-exiftool" (mark it as external to exclude it from the bundle)
require("simple-exiftool");
        ~~~~~~~~~~~~~~~~~
1 error

Steps to reproduce

Minimalist project to reproduce:

npm install -g esbuild

mkdir project
cd project

npm install simple-exiftool

echo 'require("simple-exiftool");' > index.js
esbuild --bundle index.js 

Will throw the above error.

Version

> esbuild --version
0.7.8

Same issue when using the Javascript API.

Notes

One hunch: the package.json of simple-exiftool has its main set to ./lib/exif. But it does not have that file, it only has a lib/index.js and also a trivial index.js in the root.

It works fine in our code, so maybe Nodejs' module loader is smart and falls back to index.js if the main from package.json can't be found. Possibly esbuild should do the same?

@alexkli
Copy link
Author

alexkli commented Oct 3, 2020

The NodeJS module loader seems to work as I assumed. From the spec:

LOAD_AS_DIRECTORY(X)
1. If X/package.json is a file,
   a. Parse X/package.json, and look for "main" field.
   b. If "main" is a falsy value, GOTO 2.
   c. let M = X + (json main field)
   d. LOAD_AS_FILE(M)
   e. LOAD_INDEX(M)
   f. LOAD_INDEX(X) DEPRECATED
   g. THROW "not found"
2. LOAD_INDEX(X)

...
LOAD_INDEX(X)
1. If X/index.js is a file, load X/index.js as JavaScript text. STOP
2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
3. If X/index.node is a file, load X/index.node as binary addon. STOP

Note step f. This will load index.js if the steps before did not find a file (with d being the normal file loading from main field).

@evanw evanw closed this as completed in 94268d4 Oct 3, 2020
@evanw
Copy link
Owner

evanw commented Oct 3, 2020

Thanks for reporting this. It does indeed look like esbuild is not following the spec correctly. This will be fixed in the next release.

@alexkli
Copy link
Author

alexkli commented Oct 7, 2020

Thanks, I can confirm the fix! Tested with 0.7.11.

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