Volt.JS.Specifier (Volt v0.22.1)

Copy Markdown View Source

Helpers for JavaScript module specifier strings.

Summary

Functions

Return whether a specifier names a Node.js built-in module, including a subpath of one such as timers/promises or node:fs/promises.

Return whether a specifier names a helper from @oxc-project/runtime.

Splits a JavaScript module specifier into its path-like part and query string.

Functions

node_builtin?(specifier)

@spec node_builtin?(String.t()) :: boolean()

Return whether a specifier names a Node.js built-in module, including a subpath of one such as timers/promises or node:fs/promises.

oxc_runtime_helper?(specifier)

@spec oxc_runtime_helper?(String.t()) :: boolean()

Return whether a specifier names a helper from @oxc-project/runtime.

OXC's transform imports these when it lowers syntax for a target, such as class fields below ES2022. OXC.bundle/2 provides them itself, so they are never resolved from node_modules.

split_query(specifier)

@spec split_query(String.t()) :: {String.t(), String.t()}

Splits a JavaScript module specifier into its path-like part and query string.

Unlike URL parsing, this preserves package import specifiers such as #client/constants, where the leading # is part of the JavaScript module specifier rather than a URL fragment marker.