Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 8dad2ac

Browse files
committed
Re-order bindings priority in bindings.spec.ts
1 parent 6c59d92 commit 8dad2ac

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/core/src/plugins/bindings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class BindingsPlugin
9393

9494
// Copy user's arbitrary bindings
9595
Object.assign(bindings, this.bindings);
96-
96+
9797
// Load bindings from .env file
9898
const envPath = this.envPath === true ? this.defaultEnvPath : this.envPath;
9999
if (envPath) {

packages/core/test/plugins/bindings.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,25 @@ test("BindingsPlugin: setup: loads bindings from all sources", async (t) => {
184184
const log = new NoOpLog();
185185
const tmp = await useTmp(t);
186186
const envPath = path.join(tmp, ".env");
187-
await fs.writeFile(envPath, "A=a\nB=b\nC=c");
187+
await fs.writeFile(envPath, "C=c");
188188
const obj = { c: 3 };
189189
const plugin = new BindingsPlugin(log, compat, {
190-
envPath,
191190
wasmBindings: {
191+
A: addModulePath,
192192
B: addModulePath,
193193
C: addModulePath,
194194
},
195-
bindings: { C: obj },
195+
bindings: { B: obj, C: obj },
196+
envPath,
196197
});
197198
const result = await plugin.setup();
198-
t.is(result.bindings?.A, "a");
199-
assert(result.bindings?.B);
200-
const instance = new WebAssembly.Instance(result.bindings.B);
199+
assert(result.bindings);
200+
201+
const instance = new WebAssembly.Instance(result.bindings.A);
201202
assert(typeof instance.exports.add === "function");
202203
t.is(instance.exports.add(1, 2), 3);
203-
t.is(result.bindings.C, obj);
204+
205+
t.is(result.bindings.B, obj);
206+
207+
t.is(result.bindings.C, "c");
204208
});

0 commit comments

Comments
 (0)