express icon indicating copy to clipboard operation
express copied to clipboard

modernize require/exports statements

Open dynst opened this issue 1 month ago • 1 comments

https://github.com/expressjs/express/blob/54af593b739ea44674e4a445efa15b8024f093da/lib/request.js#L17

Reduce redundancy by replacing lines like this with a destructuring assignment, and consolidate the multiple references to exports into just one or two, assigning all the exported values in one line.

dynst avatar Nov 24 '25 08:11 dynst

They're stylistic changes, but in the long term, they're also potentially useful, because these are the same changes to the code that would be needed to convert the library to ESM ( const { ... } = require('x') maps perfectly to import { ... } from 'x'; module.exports = app on its own line becomes export default app; etc).

After the style changes, it would be fairly trivial to someday convert between the 2 formats with a very simple script, so even dual-packaging CJS/ESM would become feasible by running a script at build time, instead of needing to maintain 2 identical codebases.

dynst avatar Nov 26 '25 20:11 dynst