Comparing version 2.0.0 to 2.1.0
@@ -10,3 +10,17 @@ export declare function createJiti(id: string, userOptions?: JitiOptions): Jiti; | ||
*/ | ||
export interface Jiti extends NodeRequire { | ||
export interface Jiti { | ||
/** @deprecated Prefer `await jiti.import()` for better compatibility. */ | ||
(id: string): any; | ||
/** @deprecated Prefer `jiti.esmResolve` for better compatibility. */ | ||
resolve: RequireResolve; | ||
/** @deprecated */ | ||
extensions: RequireExtensions; | ||
/** @deprecated CommonJS API */ | ||
main: Module | undefined; | ||
cache: Dict<NodeModule>; | ||
/** | ||
@@ -96,5 +110,5 @@ * Resolved options | ||
/** | ||
* Interop default export (disabled by default) | ||
* Uses the default export of modules (if exists), alongside any other named exports combined. | ||
* | ||
* Can be enabled using `JITI_INTEROP_DEFAULT=1` environment variable. | ||
* Can be disabled using `JITI_INTEROP_DEFAULT=0` environment variable. | ||
*/ | ||
@@ -182,5 +196,5 @@ interopDefault?: boolean; | ||
interopDefault?: boolean; | ||
async: boolean; | ||
async?: boolean; | ||
jsx?: boolean | JSXOptions; | ||
[key: string]: any; | ||
babel?: Record<string, any>; | ||
} | ||
@@ -187,0 +201,0 @@ |
{ | ||
"name": "jiti", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Runtime typescript and ESM support for Node.js", | ||
@@ -32,2 +32,12 @@ "repository": "unjs/jiti", | ||
"types": "./lib/jiti.d.cts", | ||
"typesVersions": { | ||
"*": { | ||
"register": [ | ||
"./lib/jiti-register.d.mts" | ||
], | ||
"native": [ | ||
"./lib/jiti.d.mts" | ||
] | ||
} | ||
}, | ||
"bin": { | ||
@@ -81,3 +91,3 @@ "jiti": "./lib/jiti-cli.mjs" | ||
"@types/babel__traverse": "^7.20.6", | ||
"@types/node": "^22.5.5", | ||
"@types/node": "^22.7.4", | ||
"@vitest/coverage-v8": "^2.1.1", | ||
@@ -91,3 +101,3 @@ "acorn": "^8.12.1", | ||
"eslint": "^9.11.0", | ||
"eslint-config-unjs": "^0.3.2", | ||
"eslint-config-unjs": "^0.4.1", | ||
"estree-walker": "^3.0.3", | ||
@@ -112,3 +122,3 @@ "fast-glob": "^3.3.2", | ||
"vitest": "^2.1.1", | ||
"vue": "^3.5.8", | ||
"vue": "^3.5.10", | ||
"webpack": "^5.94.0", | ||
@@ -115,0 +125,0 @@ "webpack-bundle-analyzer": "^4.10.2", |
@@ -21,4 +21,4 @@ # jiti | ||
- Seamless interoperability between ESM and CommonJS | ||
- Synchronous API to replace `require()` | ||
- Asynchronous API to replace `import()` | ||
- Synchronous API to replace `require()` (deprecated) | ||
- Super slim and zero dependency | ||
@@ -51,3 +51,3 @@ - Custom resolve aliases | ||
// CommonJS | ||
// CommonJS (deprecated) | ||
const { createJiti } = require("jiti"); | ||
@@ -67,3 +67,3 @@ const jiti = createJiti(__filename); | ||
CommonJS (sync - legacy): | ||
CommonJS (sync & deprecated): | ||
@@ -98,3 +98,3 @@ ```js | ||
## 🎈 `jiti/native` | ||
## 🎈 `jiti/native` | ||
@@ -155,7 +155,9 @@ You can alias `jiti` to `jiti/native` to directly depend on runtime's [`import.meta.resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) and dynamic [`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) support. This allows easing up the ecosystem transition to runtime native support by giving the same API of jiti. | ||
- Type: Boolean | ||
- Default: `false` | ||
- Default: `true` | ||
- Environment variable: `JITI_INTEROP_DEFAULT` | ||
Return the `.default` export of a module at the top level. | ||
Uses the default export of modules (if exists), alongside any other named exports combined. | ||
See [`mlly.interopDefault`](https://github.com/unjs/mlly#interopdefault) and the [implementation](https://github.com/unjs/mlly/blob/2348417d25522b98ed60ccc10eb030abb2f65744/src/cjs.ts#L59) for more info. | ||
### `alias` | ||
@@ -162,0 +164,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2084017
7810
228
14