denoify
Version:
For NPM module authors that would like to support Deno but do not want to write and maintain a port.
48 lines (47 loc) • 1.43 kB
TypeScript
import { ModuleAddress } from "../types/ModuleAddress";
import type { getInstalledVersionPackageJsonFactory } from "../getInstalledVersionPackageJson";
type GetValidImportUrl = (params: {
target: "DEFAULT EXPORT";
} | {
target: "SPECIFIC FILE";
specificImportPath: string;
}) => Promise<string>;
type Result = {
result: "SUCCESS";
getValidImportUrl: GetValidImportUrl;
} | {
result: "UNKNOWN BUILTIN";
};
export declare function resolveNodeModuleToDenoModuleFactory(params: {
userProvidedPorts: {
[nodeModuleName: string]: string;
};
dependencies: {
[nodeModuleName: string]: string;
};
devDependencies: {
[nodeModuleName: string]: string;
};
log: typeof console.log;
} & ReturnType<typeof getInstalledVersionPackageJsonFactory>): {
resolveNodeModuleToDenoModule: (params: {
nodeModuleName: string;
}) => Promise<Result>;
};
export type ValidImportUrlResult = {
couldConnect: false;
} | {
couldConnect: true;
versionFallbackWarning: string | undefined;
getValidImportUrl: GetValidImportUrl;
};
/** Exported only for tests purpose */
export declare const getValidImportUrlFactory: (params: {
moduleAddress: ModuleAddress;
} & ({
desc: "NOT LISTED AS A DEPENDENCY (PROBABLY NODE BUILTIN)";
} | {
desc: "MATCH VERSION INSTALLED IN NODE_MODULES";
version: string;
})) => Promise<ValidImportUrlResult>;
export {};