-
Notifications
You must be signed in to change notification settings - Fork 0
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
Better documentation #23
Comments
Hi @Garito, thanks for your consideration! Sorry if this is a long response, but I hope it helps.
Just to clear this up from the top, here's the terminology I use (since it can get confusing):
If it helps: So, it actually makes relatively few assumptions. However, it is safe to assume that most people (maybe like in your experience) will be coming into this using Vite, so I think we could probably flesh out the examples a bit better!
Since you are using Vite: Basically yes, in a default Vite project, your call to
Actually, no! With a default Svelte project, no additional changes at all should be required to both
Give that a shot and let me know if that works for you and if not what you're stumbling into. I'll keep this issue open so that I can use your experience and perspective when adjusting the documentation. For now, I'll just update the current Hope this helps. |
Hi @patricknelson import svelteRetag from 'svelte-retag';
import Form from 'lt-form-2';
svelteRetag({
component: Form,
tagname: 'lt-form',
attributes: ['openapi', 'schema', 'ui', 'values', 'form', 'components', 'extras' ],
}); create a test.html at the root of the project: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="module" src="src/main.js"></script>
</head>
<body>
<lt-form openapi="http://localhost:9000/openapi.json" schema="Faucet"></lt-form>
</body>
</html> start a python simple http server to test it
and i get stuck |
Sorry I gotta ask, just in case, but: Did you make sure to first run If so, then you might also need to ensure that you have your local dev server (JavaScript-based) running as well - this is what is running Vite (via SvelteKit) which will build your |
For SvelteKit, starting that server should be pretty simple too. See here: https://kit.svelte.dev/docs/creating-a-project e.g. npm create svelte@latest my-app
cd my-app
npm install
# this is the important step in your case, should start local vite dev server
npm run dev |
From package.json I'm using a python server to serve the test.html |
Yep. Technically this is all outside of the scope of How Vite works: The way it works is that it transforms code on demand. The issue you're seeing right now is that you're just loading the plain For development however, in our case, we need to perform what's called a "back-end integration" in Vite world, see: https://vitejs.dev/guide/backend-integration.html So, in your case:
This is a bit more in Vite land than Svelte-retag itself but I hope this helps. I know this is something I might want to document as well since a prime use case is for folks like us who are not running a 100% JavaScript stack. 🤔 p.s. I'd recommend using just plain Svelte instead of SvelteKit. I'm not 100% sure if it matters either way but I think it'll be simpler and less confusing if you go that way and avoid the extra stuff you don't need (layouts, routes and etc). In this case |
This is where it gets extremely variable since every person's back-end setup is going to vary (e.g. PHP vs. Python and etc). But what I do in PHP is similar to this: <?php if (isViteRunning()) { ?>
<!-- development -->
<script type="module" src="http://localhost:5173/@vite/client"></script>
<script type="module" src="http://localhost:5173/main.js"></script>
<?php } else { ?>
<!-- production -->
<script type="module" src="/dist/main.js"></script>
<?php } ?> And all that is served over p.s. Still working on some doc tweaks. |
p.s. @Garito if it helps, the attributes: ['openapi', 'schema', 'ui', 'values', 'form', 'components', 'extras' ], |
…lso integrate better with various alternative backends (such as PHP, Python, etc.).
Alright @Garito I setup a PR w/ updated docs #24. You can preview them at the following link, the most relevant section being the step-by-step instructions at https://github.com/patricknelson/svelte-retag/tree/issue-23-example-docs#how-do-i-use-it I also added some notes about backend integration which you might find useful for reference. Let me know what you think or if you have other suggestions and I can try to integrate that there. |
hi again @patricknelson ! if you move the main.js to src/lib and add this to your package.json/exports: "./main.js": {
"types": "./dist/main.d.ts",
"svelte": "./dist/main.js"
} the main.js compiles? to dist but it goes without the proper format and then it doesn't find the packages (retag and my form) I suggest you look for the proper export config to properly build you lib (perhaps as a svelte package?) If I find it first I will open a new issue with the solution At this point I really appreciate you help and effort so I thank you |
… svelte-retag in most basic form. Relocating Vercel site files to subdirectory under ./demo/vercel so this can live under ./demo/hello-world.
… svelte-retag in most basic form. Relocating Vercel site files to subdirectory under ./demo/vercel so this can live under ./demo/hello-world.
Fix for #23: Better documentation explaining how to get started
You're welcome!
I think you've gone down quite a rabbit hole! I can't help you with the specifics here since I think much of what you're dealing with here is more Vite and TypeScript specific and not related to However, based on what we discussed here, I've decided to put some additional time into building out a quick demo of the simplest possible MVP (a "Hello World") that you and others can get up and running locally so you can see Try it out, run it locally and tinker with it. Hopefully you can find a way to make it work in your particular project. Let me know if you do happen to find any bugs or issues with Thanks! |
Describe the problem
I can't follow the documentation
Describe the proposed solution
Write the documentation without assumptions
The demo code has no field name so I don't know were to put it (I assume by the demo code that should go to main.js but no explanation about how or why)
By the demo too, I assume that vite.config.js should be modified but will this need different vite.config.js for allowing to use the component as a normal component vs webcomponent. Am I right?
Would be perfect if the documentation provides a step by step instructions
thanks!
Alternatives considered
none
Importance
i cannot use svelte-retag without it
The text was updated successfully, but these errors were encountered: