Skip to main content
Version: Next

ImportMeta

Rsvim provides meta properties on import.meta.

Accessors​

url​

Get Signature​

get url(): string;

A string representation of fully qualified module URL. When the module is loaded locally, the value will be a file URL, e.g. file:///path/module.js.

tip

Rsvim doesn't support remote modules (at least for now), thus all modules are locally loaded from file system.

Example​
// Get the url of current script file.
const value = import.meta.url;
const url = new URL(import.meta.url);
if (url.protocol === "file:") {
Rsvim.cmd.echo("this module was loaded locally");
}
Returns​

string

filename​

Get Signature​

get filename(): string;

The absolute file path of current module. This property is only provided for local loaded modules, i.e. using file:// URLs.

Example​
// Unix
Rsvim.cmd.echo(import.meta.filename); // /home/alice/.rsvim.js
// Windows
Rsvim.cmd.echo(import.meta.filename); // C:\Users\alice\.rsvim.js
Returns​

string | undefined

dirname​

Get Signature​

get dirname(): string;

The absolute file path of the directory that containing current module. This property is only provided for local loaded modules, i.e. using file:// URLs.

Example​
// Unix
Rsvim.cmd.echo(import.meta.dirname); // /home/alice
// Windows
Rsvim.cmd.echo(import.meta.dirname); // C:\Users\alice
Returns​

string | undefined

main​

Get Signature​

get main(): boolean;

Whether current module is the main module that was called when starting Rsvim, i.e. the config entry point of Rsvim. See Configuration.

Example​
const isMain = import.meta.main;
Returns​

boolean

Methods​

resolve()​

resolve(specifier): string;

Resolves the URL for a specifier as if it would be imported using import(specifier).

Parameters​

ParameterTypeDescription

specifier

string

The specifier to be resolved.

Returns​

string

It returns a resolved URL by the specifier.

Example​

const url = import.meta.resolve("./utils/echo.js");