Skip to content

Conversation

@Xstoudi
Copy link
Contributor

@Xstoudi Xstoudi commented Jan 1, 2026

Move watch dependency reporting earlier in module resolution to ensure file dependencies are tracked even when parsing fails.

Fixes: #61153

Move watch dependency reporting earlier in module resolution to ensure
file dependencies are tracked even when parsing fails.

Fixes: nodejs#61153
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Jan 1, 2026
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.53%. Comparing base (ce2ec3d) to head (d112842).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/esm/loader.js 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61232      +/-   ##
==========================================
- Coverage   88.54%   88.53%   -0.02%     
==========================================
  Files         704      704              
  Lines      208734   208760      +26     
  Branches    40271    40268       -3     
==========================================
- Hits       184823   184816       -7     
- Misses      15932    15935       +3     
- Partials     7979     8009      +30     
Files with missing lines Coverage Δ
lib/internal/modules/esm/loader.js 96.96% <83.33%> (+<0.01%) ⬆️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marco-ippolito
Copy link
Member

Can you add a test?

@Xstoudi
Copy link
Contributor Author

Xstoudi commented Jan 2, 2026

Just added a test, let me know if that's too broad and shouldn't be tested through cli.

shouldFail: true,
});

try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why wrapping in try catch? it shouldnt fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a try finally, not a try catch. It shouldn't fail but wether it does or doesn't, the child processed need to be killed. The same try-finally is used every time restart is used in the file, so I just reused it.

}
});

it('should watch changes even when there is syntax errors during esm loading', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the test in a separate file instead of appending it to a test monolith? See https://github.com/nodejs/node/blob/main/doc/contributing/writing-tests.md#how-to-write-a-good-test - a monolithic test increase the chances of flakes in the CI and makes flakes even harder to debug due to the enormous output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally make sense. Let me know if it's still not the optimal way of doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node --watch won't restart after SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX] and the file is subsequently modified

5 participants