Skip to content

Commit

Permalink
feat: update to jiti v2 (#18954)
Browse files Browse the repository at this point in the history
* Bump `jiti` to v2.1.0

* Uncomment unit tests for `jiti` v2

* Remove warning about top-level `await`

* Use the `createJiti` function

* Disable `interopDefault`
  • Loading branch information
aryaemami59 authored Oct 2, 2024
1 parent 57232ff commit 5a6a053
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 260 deletions.
4 changes: 0 additions & 4 deletions docs/src/use/configure/configuration-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,6 @@ module.exports = config;
ESLint does not perform type checking on your configuration file and does not apply any settings from `tsconfig.json`.
:::

::: warning
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)
:::

### Configuration File Precedence

If you have multiple ESLint configuration files, ESLint prioritizes JavaScript files over TypeScript files. The order of precedence is as follows:
Expand Down
4 changes: 2 additions & 2 deletions lib/config/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async function loadConfigFile(filePath, allowTS) {
*/
if (allowTS && isTS && !isDeno && !isBun) {

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

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

const jiti = createJiti(__filename, { moduleCache: false });
const jiti = createJiti(__filename, { moduleCache: false, interopDefault: false });

if (typeof jiti?.import !== "function") {
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.");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"globals": "^15.0.0",
"got": "^11.8.3",
"gray-matter": "^4.0.3",
"jiti": "^1.21.6",
"jiti": "^2.1.0",
"knip": "^5.21.0",
"lint-staged": "^11.0.0",
"load-perf": "^0.2.0",
Expand Down
Loading

0 comments on commit 5a6a053

Please sign in to comment.