I'm not sure if this is a better fit for terminology or for a more implementation-focussed discussion. But I would suggest a separation of concerns when talking about module loading. The outcome would hopefully be a clear description of what happens when and what phases are responsible for which concerns.
One possible variant of this can be found here: https://github.com/jkrems/loader#module-loading
For ease of discussion, inlining the content below:
Module Loading
Module loading is split into three phases:
- Module resolution
- Resource fetching
- Module init
Module Resolution (resolve)
Given a specifier: string and referrerURL: string,
provide a url: string or a set of potential urls: string[] of a resource:
const resolve: (specifier: string, referrerURL: string) => string | string[];
Resource Fetching (fetch)
Given a resource url: string,
fetch the resource content and associated meta data.
type Resource = {
bytes?: Buffer,
contentType: string,
contentTypeParameters?: string,
};
const fetch: (url: string) => Resource;
Module Init (init)
Given a resource: Resource and a target: Module module handle,
initialize the target.
Most implementations will check the resource.contentType
to select the appropriate behavior.
const init: (target: Module, resource: Resource, Module) => void;
I'm not sure if this is a better fit for terminology or for a more implementation-focussed discussion. But I would suggest a separation of concerns when talking about module loading. The outcome would hopefully be a clear description of what happens when and what phases are responsible for which concerns.
One possible variant of this can be found here: https://github.com/jkrems/loader#module-loading
For ease of discussion, inlining the content below:
Module Loading
Module loading is split into three phases:
Module Resolution (
resolve)Given a
specifier: stringandreferrerURL: string,provide a
url: stringor a set of potentialurls: string[]of a resource:Resource Fetching (
fetch)Given a resource
url: string,fetch the resource content and associated meta data.
Module Init (
init)Given a
resource: Resourceand atarget: Modulemodule handle,initialize the
target.Most implementations will check the
resource.contentTypeto select the appropriate behavior.