Closed hagishi closed 2 months ago
1.0.5
Darwin 23.1.0 arm64 arm
When a plugin with "scoped" setting is referenced in multiple routers, the type can be referenced in the latter router, but becomes undefined at runtime when executed.
it("scoped run", async () => { const plugin = new Elysia({ name: "plugin" }).derive({ as: "scoped" }, () => { return { id: 1 }; }); const a = new Elysia().use(plugin).get("/foo", (c) => { return { id: c.id, name: "foo" }; }); const b = new Elysia().use(plugin).get("/bar", (c) => { return { id: c.id, name: "bar" }; }); console.log((await treaty(a).foo.get()).data); // show: { id: 1, name: 'foo' } console.log((await treaty(b).bar.get()).data); // show: { name: 'bar' } });
A plugin with the "scoped" setting is expected to be referenced at runtime within the scope it's defined.
The type can be referenced but becomes undefined at runtime.
No response
I executed your test cases and obtained the expected results.
{ id: 1, name: "foo", } { id: 1, name: "bar", }
Closing as unable to reproduce. Thanks.
What version of Elysia.JS is running?
1.0.5
What platform is your computer?
Darwin 23.1.0 arm64 arm
What steps can reproduce the bug?
When a plugin with "scoped" setting is referenced in multiple routers, the type can be referenced in the latter router, but becomes undefined at runtime when executed.
What is the expected behavior?
A plugin with the "scoped" setting is expected to be referenced at runtime within the scope it's defined.
What do you see instead?
The type can be referenced but becomes undefined at runtime.
Additional information
No response