Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(kit): log module id to the console when import fails #8198

Merged
merged 4 commits into from
Oct 15, 2022

Conversation

Araneline
Copy link
Contributor

πŸ”— Linked issue

nuxt/nuxt#15166

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves nuxt/nuxt#15166 - in case of error during module require/import it will be printed to the console in the form of 'Error while requiring module {module_name}: {error}'.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Oct 14, 2022

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link

netlify bot commented Oct 14, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit 3889b25
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/63498d2a1b984400074a231e

@pi0
Copy link
Member

pi0 commented Oct 14, 2022

Instead of cjs.ts util, we might add a try-catch directly to module/install.ts:45 for better stack trace. The utility in cjs a confusing name it requires a node module while in install.ts we have access to user input (not resolved) to show in custom error. It also handles ESM branch.

@Araneline
Copy link
Contributor Author

Instead of cjs.ts util, we might add a try-catch directly to module/install.ts:45 for better stack trace. The utility in cjs a confusing name it requires a node module while in install.ts we have access to user input (not resolved) to show in custom error. It also handles ESM branch.

Think I got it. Moved the try-catch block to install.ts and used an unresolved module name in the error.

@Araneline Araneline requested a review from pi0 October 15, 2022 11:21
@pi0 pi0 changed the title feat(kit): Improve error when added module is not a module fix(kit): log module id to the console when import fails Oct 15, 2022
@pi0 pi0 merged commit ddbfae1 into nuxt:main Oct 15, 2022
@pi0
Copy link
Member

pi0 commented Oct 15, 2022

Thanks!

@Araneline Araneline deleted the origin/feat/readable-module-error branch October 15, 2022 12:30
@pi0 pi0 mentioned this pull request Oct 18, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DX] Improve error when added module is no module
3 participants