Rewrite external imports into global variable access for production builds.
Summary
Functions
Scan compiled JS files for imports from external specifiers.
Generate a JS preamble that destructures external globals.
Rewrite external import declarations into direct global access.
Functions
Scan compiled JS files for imports from external specifiers.
Returns a map of specifier => [imported_names] where each name is
{:named, name}, {:default, name}, or {:namespace, name}.
Generate a JS preamble that destructures external globals.
%{"vue" => [named: "ref", named: "h"], "reka-ui" => [default: "RekaButton"]}With globals %{"vue" => "Vue", "reka-ui" => "RekaUi"} produces:
const { ref, h } = Vue;
const RekaButton = RekaUi.default;
Rewrite external import declarations into direct global access.