1 |
|
2 |
|
3 | import { Service } from './index';
|
4 | export interface NodeLoaderHooksAPI1 {
|
5 | resolve: NodeLoaderHooksAPI1.ResolveHook;
|
6 | getFormat: NodeLoaderHooksAPI1.GetFormatHook;
|
7 | transformSource: NodeLoaderHooksAPI1.TransformSourceHook;
|
8 | }
|
9 | export declare namespace NodeLoaderHooksAPI1 {
|
10 | type ResolveHook = NodeLoaderHooksAPI2.ResolveHook;
|
11 | type GetFormatHook = (url: string, context: {}, defaultGetFormat: GetFormatHook) => Promise<{
|
12 | format: NodeLoaderHooksFormat;
|
13 | }>;
|
14 | type TransformSourceHook = (source: string | Buffer, context: {
|
15 | url: string;
|
16 | format: NodeLoaderHooksFormat;
|
17 | }, defaultTransformSource: NodeLoaderHooksAPI1.TransformSourceHook) => Promise<{
|
18 | source: string | Buffer;
|
19 | }>;
|
20 | }
|
21 | export interface NodeLoaderHooksAPI2 {
|
22 | resolve: NodeLoaderHooksAPI2.ResolveHook;
|
23 | load: NodeLoaderHooksAPI2.LoadHook;
|
24 | }
|
25 | export declare namespace NodeLoaderHooksAPI2 {
|
26 | type ResolveHook = (specifier: string, context: {
|
27 | conditions?: NodeImportConditions;
|
28 | importAssertions?: NodeImportAssertions;
|
29 | parentURL: string;
|
30 | }, defaultResolve: ResolveHook) => Promise<{
|
31 | url: string;
|
32 | format?: NodeLoaderHooksFormat;
|
33 | shortCircuit?: boolean;
|
34 | }>;
|
35 | type LoadHook = (url: string, context: {
|
36 | format: NodeLoaderHooksFormat | null | undefined;
|
37 | importAssertions?: NodeImportAssertions;
|
38 | }, defaultLoad: NodeLoaderHooksAPI2['load']) => Promise<{
|
39 | format: NodeLoaderHooksFormat;
|
40 | source: string | Buffer | undefined;
|
41 | shortCircuit?: boolean;
|
42 | }>;
|
43 | type NodeImportConditions = unknown;
|
44 | interface NodeImportAssertions {
|
45 | type?: 'json';
|
46 | }
|
47 | }
|
48 | export declare type NodeLoaderHooksFormat = 'builtin' | 'commonjs' | 'dynamic' | 'json' | 'module' | 'wasm';
|
49 | export declare type NodeImportConditions = unknown;
|
50 | export interface NodeImportAssertions {
|
51 | type?: 'json';
|
52 | }
|
53 | export declare function createEsmHooks(tsNodeService: Service): NodeLoaderHooksAPI1 | NodeLoaderHooksAPI2;
|