Comparing version 0.0.2 to 0.0.3
@@ -74,3 +74,3 @@ import * as bundle_require from 'bundle-require'; | ||
*/ | ||
parentURL: string; | ||
parentURL: string | URL; | ||
/** | ||
@@ -87,8 +87,4 @@ * The `with` option for native `import()` call. | ||
declare function isNativeTsImportSupported(): Promise<boolean>; | ||
declare function isTypeScriptFile(path: string): boolean; | ||
/** | ||
* Detect the 'auto' loader to use for importing the file. | ||
*/ | ||
declare function detectLoader(): Promise<SupportedLoader>; | ||
declare function isTypeScriptFile(path: string): RegExpMatchArray | null; | ||
/** | ||
* Import a TypeScript module at runtime. | ||
@@ -99,3 +95,3 @@ * | ||
*/ | ||
declare function importTs<T = any>(path: string, parentURL: string): Promise<T>; | ||
declare function importTs<T = any>(path: string, parentURL: string | URL): Promise<T>; | ||
/** | ||
@@ -109,2 +105,2 @@ * Import a TypeScript module at runtime. | ||
export { type ImportTsOptions, type SupportedLoader, detectLoader, importTs as import, importTs, isNativeTsImportSupported, isTypeScriptFile }; | ||
export { type ImportTsOptions, type SupportedLoader, importTs as import, importTs, isNativeTsImportSupported, isTypeScriptFile }; |
{ | ||
"name": "importx", | ||
"type": "module", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"packageManager": "pnpm@9.0.2", | ||
@@ -70,2 +70,3 @@ "description": "Unified tool for importing TypeScript modules at runtime", | ||
"lint-staged": "^15.2.2", | ||
"picocolors": "^1.0.0", | ||
"pnpm": "^9.0.2", | ||
@@ -72,0 +73,0 @@ "rimraf": "^5.0.5", |
@@ -47,14 +47,29 @@ # importx | ||
graph TD | ||
A[Auto] --> IsTS{{"Is importing TypeScript file?"}} | ||
A((Auto)) --> IsTS{{"Is importing a TypeScript file?"}} | ||
IsTS --> |No| Cache{{"Import cache?"}} | ||
Cache --> |Yes| B([native import]) | ||
Cache --> |No| tsx1[tsx] | ||
Cache --> |true,null| Native1(["native import()"]) | ||
Cache --> |false| F | ||
Cache2 --> |false| F | ||
IsTS --> |Yes| Cache2{{"Import cache?"}} | ||
Cache2 --> |Yes| D{{"Supports native TypeScript?"}} | ||
Cache2 --> |No| tsx2[tsx] | ||
D --> |Yes| E([native import]) | ||
D --> |No| F{{"Is Node.js version range supports tsx?"}} | ||
F --> |Yes| G[tsx] | ||
F --> |No| H[jiti] | ||
Cache2 --> |true,null| D{{"Supports native TypeScript?"}} | ||
D --> |No| Cache3{{"Import cache?"}} | ||
D --> |Yes| Native2(["native import()"]) | ||
Cache3 --> |true| Jiti1([jiti]) | ||
Cache3 --> |null| F{{"Is Node.js version range supports tsx?"}} | ||
F --> |Yes| Tsx3([tsx]) | ||
F --> |No| Jiti2([jiti]) | ||
classDef auto fill:#0f82,stroke:#0f83,stroke-width:2px; | ||
classDef question fill:#f9f2,stroke:#f9f3,stroke-width:2px; | ||
classDef cache fill:#eb527120,stroke:#eb527133,stroke-width:2px; | ||
classDef native fill:#8882,stroke:#8883,stroke-width:2px; | ||
classDef tsx fill:#09f2,stroke:#09f3,stroke-width:2px; | ||
classDef jiti fill:#ffde2220,stroke:#ffde2230,stroke-width:2px; | ||
class A auto; | ||
class IsTS,D,F question; | ||
class Cache,Cache2,Cache3 cache; | ||
class Native1,Native2 native; | ||
class Tsx1,Tsx2,Tsx3 tsx; | ||
class Jiti1,Jiti2 jiti; | ||
``` | ||
@@ -137,5 +152,7 @@ | ||
Importing a TypeScript module with `importx`: | ||
<!-- TABLE_START --> | ||
> Generated with version v0.0.1 at 2024-05-11T03:58:02.482Z | ||
> Generated with version v0.0.2 at 2024-05-11T04:17:16.249Z | ||
@@ -142,0 +159,0 @@ | | native | tsx | jiti | bundle-require | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20358
190
19
194