Repository navigation
ES modules - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the project from CommonJS to ES modules, modernizes the Node support baseline, and switches the test runner from Jest to Vitest.
Changes:
- Convert
src/modules fromrequire/module.exportstoimport/exportand set"type": "module". - Replace Jest with Vitest (new
test/vitest.config.js, updated test files, updatednpm testscript). - Raise supported Node versions (package engines + CI matrix).
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/vitest.config.js | Adds Vitest configuration (timeout). |
| test/startup.test.js | Updates tests to Vitest + async/await patterns. |
| test/responses.test.js | Updates tests to Vitest + ESM patterns and adjusts directory listing expectation. |
| test/jest.config.js | Removes Jest configuration. |
| test/errors.test.js | Updates tests to Vitest + async/await patterns. |
| src/server.js | Converts server module to ESM imports/exports. |
| src/serveFile.js | Converts to ESM and adds __dirname derivation for bundled favicon path. |
| src/serveDirectory.js | Converts to ESM and replaces JSON require with createRequire. |
| src/mimeType.js | Converts exports to ESM. |
| src/log.js | Converts to ESM and replaces JSON require with createRequire. |
| src/httpError.js | Converts HttpError to an ESM export. |
| src/cli.js | Converts CLI entrypoint to ESM imports. |
| package.json | Declares ESM, replaces main with exports, switches test script to Vitest, bumps Node engines. |
| .github/workflows/test.yml | Updates Node versions used in CI matrix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+105
to
106
| const fileStat = await fsp.stat(path.join(import.meta.dirname, 'responses.test.js')) | ||
| expect(response.status).toEqual(416) |
Comment on lines
68
to
70
| if (fileStat.isFile()) { | ||
| return await serveFile({ basePath, requestedPath: '/favicon.ico', fileStat, response}) | ||
| return await serveFile({ basePath, requestedPath: '/favicon.ico', fileStat, response }) | ||
| } |
Comment on lines
+6
to
+10
| "type": "module", | ||
| "bin": { | ||
| "httpdir": "src/cli.js" | ||
| }, | ||
| "main": "src/server.js", | ||
| "exports": { |
Comment on lines
13
to
15
| "scripts": { | ||
| "test": "jest --config=test/jest.config.js" | ||
| "test": "vitest run --config=test/vitest.config.js" | ||
| }, |
Comment on lines
+63
to
64
| const fileStat = await fsp.stat(path.join(import.meta.dirname, 'responses.test.js')) | ||
| expect(response.status).toEqual(200) |
Comment on lines
+84
to
85
| const fileStat = await fsp.stat(path.join(import.meta.dirname, 'responses.test.js')) | ||
| expect(response.status).toEqual(206) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5 +/- ##
==========================================
- Coverage 83.02% 76.83% -6.20%
==========================================
Files 6 8 +2
Lines 218 505 +287
Branches 32 67 +35
==========================================
+ Hits 181 388 +207
- Misses 34 115 +81
+ Partials 3 2 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.