Skip to content

Commit 5a6a053

Browse files
authored
feat: update to jiti v2 (#18954)
* Bump `jiti` to v2.1.0 * Uncomment unit tests for `jiti` v2 * Remove warning about top-level `await` * Use the `createJiti` function * Disable `interopDefault`
1 parent 57232ff commit 5a6a053

4 files changed

Lines changed: 252 additions & 260 deletions

File tree

docs/src/use/configure/configuration-files.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,6 @@ module.exports = config;
577577
ESLint does not perform type checking on your configuration file and does not apply any settings from `tsconfig.json`.
578578
:::
579579

580-
::: warning
581-
As of now, [`jiti`](https://github.com/unjs/jiti) does not support [top-level `await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await)
582-
:::
583-
584580
### Configuration File Precedence
585581

586582
If you have multiple ESLint configuration files, ESLint prioritizes JavaScript files over TypeScript files. The order of precedence is as follows:

lib/config/config-loader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async function loadConfigFile(filePath, allowTS) {
173173
*/
174174
if (allowTS && isTS && !isDeno && !isBun) {
175175

176-
const createJiti = await import("jiti").then(jitiModule => jitiModule.default, () => {
176+
const createJiti = await import("jiti").then(jitiModule => (typeof jitiModule?.createJiti === "function" ? jitiModule.createJiti : jitiModule.default), () => {
177177
throw new Error("The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.");
178178
});
179179

@@ -182,7 +182,7 @@ async function loadConfigFile(filePath, allowTS) {
182182
* config file when the last modified timestamp changes.
183183
*/
184184

185-
const jiti = createJiti(__filename, { moduleCache: false });
185+
const jiti = createJiti(__filename, { moduleCache: false, interopDefault: false });
186186

187187
if (typeof jiti?.import !== "function") {
188188
throw new Error("You are using an outdated version of the 'jiti' library. Please update to the latest version of 'jiti' to ensure compatibility and access to the latest features.");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"globals": "^15.0.0",
168168
"got": "^11.8.3",
169169
"gray-matter": "^4.0.3",
170-
"jiti": "^1.21.6",
170+
"jiti": "^2.1.0",
171171
"knip": "^5.21.0",
172172
"lint-staged": "^11.0.0",
173173
"load-perf": "^0.2.0",

0 commit comments

Comments
 (0)