-
Notifications
You must be signed in to change notification settings - Fork 930
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
Sveltekit app starter template/generator #9133
Comments
I've since looked more into Bit custom environments. I can see that the current Svelte env uses Svelte 3.x I recommend updating the
|
I believe that the Svelte env can mostly be reused with a few changes as follows:
{
"policy": {
"peers": [
// react packages are required for the env's rendering of component docs, and are not related to
// how the env processes your svelte component code
{
"name": "@sveltejs/kit",
"supportedRange": "^2.0.0 || ^2.5.0",
"version": "^2.5.0",
"force": true
},
{
"name": "@sveltejs/adapter-auto",
"supportedRange": "^3.0.0 || ^3.2.4",
"version": "^3.2.4",
"force": true
},
{
"name": "svelte",
"supportedRange": "^2.0.0 || ^2.5.0",
"version": "^2.5.0",
"force": true
},
{
"name": "vite",
"supportedRange": "^4.0.0 || ^4.2.18",
"version": "^4.2.18",
"force": true
},
{
"name": "react",
"version": "^18.0.0",
"supportedRange": "^17.0.0 || ^18.0.0",
"hidden": true
},
// more ...
]
}
}
export class SvelteKitEnv extends SvelteEnv {
// ideally replace with ViteTester
tester(): EnvHandler<Tester> {
return JestTester.from({
jest: require.resolve('jest'),
config: require.resolve('./config/jest/jest.config'),
});
}
starters() {
// TODO: new starter for sveltekit needed
return StarterList.from([SvelteKitWorkspaceStarter.from()]);
}
generators() {
return TemplateList.from([
SvelteComponentTemplate.from(),
// TODO
SvelteKitEnvTemplate.from(),
SvelteKitAppTemplate.from()
// XTRAS
SvelteKitPageTemplate.from()
]);
}
}
// TODO reactor to extend HtmlEnvInterface instead, when html env has been ported over to new envs structure
export interface SvelteEnvInterface extends ReactEnvInterface, DependencyEnv {} Then in the |
import { sveltekit } from '@sveltejs/kit/vite'
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()]
}
export default config
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
};
export default config |
For vitest config with testing-library as per https://testing-library.com/docs/svelte-testing-library/setup/ Configure add the following dev dependencies to the previous list:
import {defineConfig} from 'vitest/config'
import {sveltekit} from '@sveltejs/kit/vite'
import {svelteTesting} from '@testing-library/svelte/vite'
export default defineConfig({
plugins: [sveltekit(), svelteTesting()],
test: {
environment: 'jsdom',
setupFiles: ['./vitest-setup.js'],
},
}) That should do it? :) |
hi, thanks for the feedback. thanks for your feedbacks, we'll try to use it to speed things up! |
@itaymendel Thanks for the quick response. What is the concrete issue with consuming ESM by Bit? I can see that sveltekit was converted to ESM a few years ago Looking forward to to port later this year. In the meantime, I guess I can just import the svelte components from a regular sveltekit app as part of an Nx or Pnpm monorepo f.ex. I've seen a few articles on Bit/Nx integration. I've just gone through your getting started youtube playlist. P.S: Your series seem to be missing some important chapters:
Perhaps these are advanced topics? I'll check out some more videos and docs. |
Turns out I was missing info on the Bitmap file which you quickly skipped over. There you can map components and apps to a specific environment (or via bit CLI). I was curious how I would fork an env, customize it and export it to cloud for reuse and community.
So it looks like I can find a Bit env such as https://bit.cloud/frontend/svelte/svelte-env and fork it locally via the component ID, modify it and re-export it to my own Bit cloud account. |
Bit supports ESM, it's just that the current plugin/env for Svelte with Bit is built in CJS, and this needs to be ported to ESM, as using ESM from CJS is not something we want to do here. for example, you can see that here we don't have require.resolve - https://bit.cloud/bitdev/react/react-env/~code/react-env.bit-env.ts |
Description
I'd love to see a SvelteKit starter template for Bits.
I managed to created a Svelte on Bits demo app based on:
Which I found via #6664
Describe the solution you'd like
A generator for Sveltekit 2. I would think it is not that difficult, as the Svelte app is just a simple Svelte app with a few additional files added for the Bit dev server to use to showcase it.
I wonder if I could manually create a new named Bit scope, run the Sveltekit generator there and then manually insert the Bit dev server files required, hooked up to the app?
I'd also much appreciate a blog post and docs, announcing the availability of the Svelte option with some more in-depth coverage of how to use it and get started. Cheers!
Describe alternatives you've considered
See above
Additional context
The text was updated successfully, but these errors were encountered: