-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Module compatible with SvelteKit & Vite SSR #2126
Comments
This is a build problem, not a library problem. You can import a browser-compatible/optimized version directly from skypack, as shown in the readme. I'm not familiar with SveletKit and Vite, but some of the The proper solution will be to migrate all of Octokit to native ES Modules which is something I'm preparing right now, but it's a big project and I need to finish some other work first. I hope to finish the transition by end of September. If there is something simple I can do to make Octokit easier to use for Svelte users please let me know, I can create follow up issues and address them. But I'll close this issue as there is nothing actionable to do for me as things stand right now |
Any updates with this? I'm facing the exact same issue too. |
I worked around this problem by aliasing // svelte.config.js
const config = {
// ...
kit: {
// ...
vite: {
resolve: {
alias: {
'node-fetch': 'isomorphic-fetch',
},
},
},
},
};
export default config; @gr2m Maybe it would be possible to use |
Unfortunately the JS octokit libraries no longer have an active maintainer. You can read about it in this discussion, subscribe to it for further updates. |
Bummer. In any case, I hope my answer will help people who search for this issue and end up here, like I did. |
Yep, this is helpful, thank you! |
Thank you! |
For anyone confused by this, the file in the default
|
This import worked for me as of 16 July 2022 with version ^3.44.0 of SvelteKit: import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
resolve: {
alias: {
'node-fetch': 'isomorphic-fetch',
},
}
};
export default config; And the import in index.svelte like so: import { Octokit } from '@octokit/core'; |
1. **Octokit:** Added Octokit Official clients for the GitHub API. 2. **Isomorphic-fetch:** Octokit was not working with default node-fetch, So had to use Isomorphic-fetch. [Issue](octokit/octokit.js#2126) 3. **Session storage:** Added fetch data to session storage, So doesn't need to fetch it again while routing to `UserCardComponent` to `UserDetailsView`
this also solves
from // expose Promise
Body.Promise = global.Promise; |
For those subscribed to this issue, we will be removing |
Probably obvious to most, but make sure you've also installed |
Please avoid duplicates
Reproducible test case
Please select the environment(s) that are relevant to your bug report
Version
[email protected]
[email protected]
What happened?
Octokit.js is supposed to be compatible with browsers, so I expect it to be compatible with frameswork aswell.
Using Vite bundler, the resolve of packages is not working.
Following some Error Logs using latest svelteKit and Vite, as well an Workaround hack, provided by @GrygrFlzr (not sure if he is willing to give some more backround insights, how to fix)
Code want to run
Error getting
After setting octokit as noExternal wiht
kit.vite.ssr.noExternal: ["octokit"]
, getting the followingtrying to import from
octokit/dist-web
trying to import from
octokit/dist-web
and added octokit to noExternalAmazing workaround fix by @GrygrFlzr: https://gist.github.com/alexanderniebuhr/12a60bde6faf44d4f519e93b1765ec99
I am not very safe with modules and exports and imports, but it seems that there might be just some mappings to update. Sure you have some idea, or can get around it.
keep me updated.
cheers
Would you be interested in contributing a fix?
The text was updated successfully, but these errors were encountered: