Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions templates/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,25 @@ function _uniffiLoad() {
{%- endmatch %}

// Get the path to the lib to load

// 1. Use the library passed in the environment with the highest precidence
let libraryPath = process.env[`${library.toUpperCase()}_PATH`];
Copy link
Copy Markdown
Collaborator Author

@1egoman 1egoman Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Before merging, this needs to be documented somewhere (maybe in --help?)


// 2. Or, fallback to the at build time defined mechanism
{% match out_lib_path -%}
{%- when LibPath::Omitted -%}
const libraryPath = join(libraryDirectory, `${library}.${ext}`);
if (!libraryPath) {
libraryPath = join(libraryDirectory, `${library}.${ext}`);
}

{% when LibPath::Literal(literal) %}
{%- if literal.is_absolute() -%}
const libraryPath = "{{ literal }}";
{%- else -%}
const libraryPath = join(libraryDirectory, "{{ literal }}");
{%- endif -%}
if (!libraryPath) {
{%- if literal.is_absolute() -%}
libraryPath = "{{ literal }}";
{%- else -%}
libraryPath = join(libraryDirectory, "{{ literal }}");
{%- endif -%}
}

{% when LibPath::Modules(mods) %}
let libPathModule;
Expand Down Expand Up @@ -105,7 +114,9 @@ function _uniffiLoad() {
throw new Error(messageFragments.join('\n'));
}

const libraryPath = libPathModule.default().path;
if (!libraryPath) {
libraryPath = libPathModule.default().path;
}

{% endmatch %}

Expand Down
Loading