Skip to content

ES modules - #5

Merged
johansatge merged 1 commit into
masterfrom
es-modules
May 6, 2026
Merged

johansatge merged 1 commit into
masterfrom
es-modules

Conversation

@johansatge

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 from require/module.exports to import/export and set "type": "module".
  • Replace Jest with Vitest (new test/vitest.config.js, updated test files, updated npm test script).
  • 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 thread test/responses.test.js
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 thread src/serveFile.js
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 thread package.json
Comment on lines +6 to +10
"type": "module",
"bin": {
"httpdir": "src/cli.js"
},
"main": "src/server.js",
"exports": {
Comment thread package.json
Comment on lines 13 to 15
"scripts": {
"test": "jest --config=test/jest.config.js"
"test": "vitest run --config=test/vitest.config.js"
},
Comment thread test/responses.test.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 thread test/responses.test.js
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

codecov Bot commented May 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.83%. Comparing base (9b260d7) to head (c77f90d).

Files with missing lines Patch % Lines
src/cli.js 0.00% 2 Missing ⚠️
src/serveFile.js 88.88% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 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.

@johansatge
johansatge merged commit 71be2ff into master May 6, 2026
3 of 4 checks passed
@johansatge
johansatge deleted the es-modules branch May 6, 2026 19:18
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