Commit c8de061
committed
feat: support loading ESM config files
In Node.js v24.0.0, v22.12.0, and v20.19.0, ECMAScript modules can be
loaded via `require` in a CommonJS context without an experimental flag.
When a system already uses ESM for the majority of its code it can be
inconsistent and confusing to have a single CommonJS file.
This change allows n-test to load a config file that's an ECMAScript
module by looking for the default export. We only try the `default`
property of the imported config file if it's not an array.
See https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require
for more information on how this works and why we use `__esModule` and
the `default` property.1 parent c4e09e7 commit c8de061
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| |||
0 commit comments