lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
8.61k stars 448 forks source link

Update index.md - Added specific configuration example for Svelte/Kit #1429

Closed lolcabanon closed 5 months ago

lolcabanon commented 5 months ago

Added specific configuration example for Svelte/Kit

I am not sure exactly what to include, since I tested only for sveltekit with adapter-node specifically.

I couldn't build successfully until I moved oslo from devDependencies to dependencies. I tried with optimizeDeps: { exclude: ["oslo"] } before, but it did not solve my issue. The vite build process could succeed, but then the @sveltejs/adapter-node step would fail.

Here's the stack in case someone have the same problem :

> Using @sveltejs/adapter-node
error during build:
RollupError: Unexpected character '\u{7f}'
    at error (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
    at parseError (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/parseAst.js:972:9)
    at convertNode (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/parseAst.js:2061:12)
    at convertProgram (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/parseAst.js:965:12)
    at parseAstAsync (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/parseAst.js:2112:12)
    at async Module.tryParseAsync (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/node-entry.js:13571:20)
    at async Module.setSource (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/node-entry.js:13152:35)
    at async ModuleLoader.addModuleSource (file:///home/$USER/sveltekit-demo/node_modules/.pnpm/rollup@4.10.0/node_modules/rollup/dist/es/shared/node-entry.js:17847:13)
 ELIFECYCLE  Command failed with exit code 1.
pilcrowOnPaper commented 5 months ago

I'm curious why you installed it as a dev dependency?

ollema commented 5 months ago

as per: https://kit.svelte.dev/docs/adapter-node#deploying

Development dependencies will be bundled into your app using Rollup. To control whether a given package is bundled or externalised, place it in devDependencies or dependencies respectively in your package.json.

lolcabanon commented 5 months ago

I'm curious why you installed it as a dev dependency?

Since SvelteKit bundle the app, most dependencies are in fact devDependencies.

The prod app can be executed by copying the build directory only without npm install if there are no actual runtime specific or impossible to bundle dependencies (as oslo seems to be). (I also have dotenv for my loader script and one other I can't remember, but all the other deps are devDependencies.)

In my case I only run npm install --prod so it is much faster and lighter like this.

I tought this was the way for SvelteKit lol am I doin this wrong?

pilcrowOnPaper commented 5 months ago

Ah, makes sense TIL. I think we can remove the optimizeDeps from the docs then

lolcabanon commented 5 months ago

I'll review the PR with relevant infos!

pilcrowOnPaper commented 5 months ago

Might be better to just add a warning to the install step? Something like "Oslo must be installed as a regular dependency, not a dev dependency."

lolcabanon commented 5 months ago

Updated both sections. Let me know what you think of it!

Also thanks @ollema for the documentation link. :smiley:

pilcrowOnPaper commented 5 months ago

Thanks!

lolcabanon commented 5 months ago

My pleasure! Thanks for the update to v3! The migration went smooth (except when I tried to build lol!) :smile: