Closed KeyboardDabbler closed 5 months ago
I found some information in the nuxt documentation link. I have overcome the error for now without manually making changes to the module files.
I will reference the following If you encounter these errors, the issue is almost certainly with the upstream library. They need to fix their library to support being imported by Node.
Just for the record, #341 caused this error. I have it in all of my projects... Apparently, neither Nestjs nor Nextjs support es modules properly. Because there weren't too many Jellyfin API changes, I have been procrastinating finding a solution for it, but you'll probably have to experiment with TS targets and es modules. If I find anything, I'll post it here.
Conversation via Element:
@Meierschlumpf helped me with https://github.com/ajnart/homarr/pull/1016 . Now working again for our project.
I'm having this issue with SvelteKit is there any fix for it?
same here with sveltekit :/
As I commented previously this library only ships as an ES module. If you are working in an ecosystem that does not support ES modules, you may need to have a build step to convert the library to a compatible module format.
I am curious if distributing *.mjs
files would help in some of these cases, but someone would have to test that.
If you are working in an ecosystem that does not support ES modules, you may need to have a build step to convert the library to a compatible module format.
According to the SvelteKit docs, it seems they do support ESM but only when "type": "module"
is indicated in the package.json, which it doesn't seem to be for tslib
(the import that's failing):
https://kit.svelte.dev/docs/faq#how-do-i-fix-the-error-i-m-getting-trying-to-include-a-package
https://github.com/microsoft/tslib/blob/main/package.json
It doesn't seem tslib
wants to change this either for backwards compatibility reasons:
https://github.com/microsoft/tslib/issues/180
In dev mode, Vite actually suggests importing using the following. I wonder if this would work as a workaround, but I'm not exactly sure how to change it given that the import for tslib
seems to be autogenerated and not actually written this way in the source files.
import pkg from '../node_modules/tslib/tslib.es6.js';
const { __awaiter } = pkg;
Any updates on this? I've not found a way around it.
From my perspective the Jellyfin SDK is being published as an ES module with a transient dependancy which is a CJS module. (at least this is how Vite sees it).
tslib seems to have no intention of bundling their library as an ES module for compatibility reasons which leaves this SDK in an unusable state for myself and others.
I'm just going to either not use the SDK or copy the source files across directly but obviously neither of these solutions are ideal
For what it's worth I found a middle ground solution which is good-enough for me it's probably dumb but hopefully someone else might find it useful too.
I created a package patch where I defined the tslib
package as module
by creating a package.json
file within @jellyfin/sdk/lib/node_modules/tslib/
.
The contents of the patch file:
new file mode 100644
index 0000000..1632c2c
--- /dev/null
+++ b/node_modules/@jellyfin/sdk/lib/node_modules/tslib/package.json
@@ -0,0 +1 @@
+{"type": "module"}
\ No newline at end of file
This should be fixed in the next release, but if you would like to confirm before then, you can test the latest unstable
tag.
Update: I've confirmed the issue is fixed for jest in jellyfin-expo at least.
I have started a project built on nuxt 3.3.1, added the @jellyfin/sdk library to handle user Auth and future api requests. Has anyone had any experience using this stack, is the below a bug or a error on my side? The login end point authenticateUserByName() is working and in response giving me the AccessToken. However there's an issue with specifically, the awaiter function in this library is not working properly with Nuxt. As a result, i have had to manually make changes to the Node.js module files in order to get the library to work.