Skip to content

Commit

Permalink
fix(deps): bump jiti to v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Sep 26, 2024
1 parent 0e56ab4 commit 066b485
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
22 changes: 17 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"ebec": "^2.3.0",
"fast-glob": "^3.3.2",
"flat": "^5.0.2",
"jiti": "^1.21.6",
"jiti": "^2.0.0",
"yaml": "^2.5.0"
}
}
15 changes: 8 additions & 7 deletions src/loader/built-in/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/

import { BaseError } from 'ebec';
import type { JITI } from 'jiti';
import createJITI from 'jiti';
import { createJiti } from 'jiti';
import { pathToFileURL } from 'node:url';
import type { LocatorInfo } from '../../../locator';
import {
Expand All @@ -26,13 +25,15 @@ import type { Loader } from '../../type';
import type { ModuleLoadOptions } from './type';
import { toModuleRecord } from './utils';

type Jiti = ReturnType<typeof createJiti>;

export class ModuleLoader implements Loader {
protected jiti : JITI;
protected instance : Jiti;

constructor() {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.jiti = createJITI(undefined, {
this.instance = createJiti(undefined, {
extensions: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],
});
}
Expand All @@ -56,7 +57,7 @@ export class ModuleLoader implements Loader {
if (isTsNodeRuntimeEnvironment()) {
output = this.loadSync(input);
} else {
output = this.jiti(input);
output = this.instance(input);
}
}

Expand All @@ -77,7 +78,7 @@ export class ModuleLoader implements Loader {
throw e;
}

output = this.jiti(input);
output = this.instance(input);
}

return toModuleRecord(output);
Expand All @@ -99,7 +100,7 @@ export class ModuleLoader implements Loader {
return require(id);
}

return await import(id);
return await this.instance.import(id);
} catch (e) {
/* istanbul ignore next */
if (
Expand Down

0 comments on commit 066b485

Please sign in to comment.