Skip to content

fix(vm): improve error when module is not found#5053

Merged
sheremet-va merged 5 commits intovitest-dev:mainfrom
hi-ogawa:fix-vm-internal-resolve-error
Feb 6, 2024
Merged

fix(vm): improve error when module is not found#5053
sheremet-va merged 5 commits intovitest-dev:mainfrom
hi-ogawa:fix-vm-internal-resolve-error

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Jan 27, 2024

Description

Follow up of #5045 (review)

It turned out the "non throwing" behavior of import.meta.resolve is only for path based import such as ./bad-path.js but not for bad-package. For the first case, Vitest throws an error during readFileSync while NodeJS still throws ERR_MODULE_NOT_FOUND, so this is a potential inconsistency, but I suppose it's very unlikely that this difference would affect Vitest user in any critical way.
Nonetheless, I'll see if there is a way to align the behavior closer to NodeJS instead of surfacing "readFileSync" exception.

references

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Loading
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

Successfully merging this pull request may close these issues.

2 participants