sindresorhus / import-from

Import a module like with `require()` but from a given path
MIT License
86 stars 8 forks source link

Add a module not found error instead of assertion error #1

Closed ranyitz closed 7 years ago

ranyitz commented 7 years ago

If the module wasn't found, req-from is throwing an assertion error, this is because resolve-from is returning null in case the module wasn't found.

The PR will throw a module not found like error, with the same code and message.

another option would be to extend resolve-from in order to get the original error if that's a better solution.

sindresorhus commented 7 years ago

I would rather change resolve-from to be like this module. Throw on the main export and silent when using resolveFrom.silent().

ranyitz commented 7 years ago

I agree,

The changes are on this PR - https://github.com/sindresorhus/resolve-from/pull/4

sindresorhus commented 7 years ago

resolve-from@3 is out. Can you update this PR?

sindresorhus commented 7 years ago

You also need to fix the merge conflict.

ranyitz commented 7 years ago

Updated, thanks for the quick response !

sindresorhus commented 7 years ago

Thank you @ranyitz :)

ranyitz commented 7 years ago

No problem, Thank you @sindresorhus @SamVerschueren :)