Skip to content

Commit

Permalink
types(ses): Align module descriptor types
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Jul 11, 2024
1 parent 6a4b16d commit d3b447f
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions packages/ses/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type Lockdown = (options?: LockdownOptions) => void;
export type __LiveExportMap__ = Record<string, [string, boolean]>;
export type __FixedExportMap__ = Record<string, [string]>;

export interface PrecompiledStaticModuleInterface {
export interface PrecompiledModuleSource {
imports: Array<string>;
exports: Array<string>;
reexports: Array<string>;
Expand All @@ -55,7 +55,7 @@ export interface PrecompiledStaticModuleInterface {
__fixedExportMap__: __FixedExportMap__;
}

export interface ThirdPartyStaticModuleInterface {
export interface VirtualModuleSource {
imports: Array<string>;
exports: Array<string>;
/**
Expand All @@ -68,20 +68,39 @@ export interface ThirdPartyStaticModuleInterface {
): void;
}

export type FinalStaticModuleType =
| PrecompiledStaticModuleInterface
| ThirdPartyStaticModuleInterface;
export type ModuleSource = PrecompiledModuleSource | VirtualModuleSource;

export interface RedirectStaticModuleInterface {
export interface RedirectModuleDescriptor {
specifier: string;
record?: FinalStaticModuleType;
record?: ModuleSource;
importMeta?: any;
compartment?: Compartment;
}

export type StaticModuleType =
| RedirectStaticModuleInterface
| FinalStaticModuleType;
export interface ReferenceModuleDescriptor {
specifier: string;
record?: ModuleSource;
importMeta?: any;
compartment?: Compartment;
}

export type ModuleDescriptor =
// These descriptor shapes are needed for XS parity:
// | SourceModuleDescriptor
// | NamespaceModuleDescriptor
// To be deprecated:
| RedirectModuleDescriptor
| ReferenceModuleDescriptor
| ModuleExportsNamespace

Check failure on line 94 in packages/ses/types.d.ts

View workflow job for this annotation

GitHub Actions / lint (18.x, ubuntu-latest)

'ModuleExportsNamespace' was used before it was defined

Check failure on line 94 in packages/ses/types.d.ts

View workflow job for this annotation

GitHub Actions / lint (20.x, ubuntu-latest)

'ModuleExportsNamespace' was used before it was defined
| VirtualModuleSource
| PrecompiledModuleSource;

// Deprecated type aliases:
export type PrecompiledStaticModuleInterface = PrecompiledModuleSource;
export type ThirdPartyStaticModuleInterface = VirtualModuleSource;
export type RedirectStaticModuleInterface = RedirectModuleDescriptor;
export type FinalStaticModuleType = ModuleSource;
export type StaticModuleType = RedirectStaticModuleInterface | ModuleSource;

export type ModuleExportsNamespace = Record<string, any>;

Expand All @@ -90,12 +109,12 @@ export type ResolveHook = (
importSpecifier: string,
referrerSpecifier: string,
) => string;
export type ModuleMap = Record<string, string | ModuleExportsNamespace>;
export type ModuleMap = Record<string, string | ModuleDescriptor>;
export type ModuleMapHook = (
moduleSpecifier: string,
) => string | ModuleExportsNamespace | void;
export type ImportHook = (moduleSpecifier: string) => Promise<StaticModuleType>;
export type ImportNowHook = (moduleSpecifier: string) => StaticModuleType;
) => ModuleDescriptor | undefined;
export type ImportHook = (moduleSpecifier: string) => Promise<ModuleDescriptor>;
export type ImportNowHook = (moduleSpecifier: string) => ModuleDescriptor;

export interface CompartmentOptions {
name?: string;
Expand Down

0 comments on commit d3b447f

Please sign in to comment.