Skip to content
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

Switch to SvelteKit/Svelte-library style project setup / publishing #161

Closed
vatro opened this issue Sep 5, 2022 · 3 comments
Closed

Switch to SvelteKit/Svelte-library style project setup / publishing #161

vatro opened this issue Sep 5, 2022 · 3 comments
Assignees
Labels
code quality project setup general project setup issue
Milestone

Comments

@vatro
Copy link
Owner

vatro commented Sep 5, 2022

I've been struggling with project setup issues ever since, especially the correct TypeScript setup. Currently, I'm pretty annoyed by some strange / inconsistent TS behavior inside the svelthree-project vs. svelthree-package installed in newest SvelteKit-app, so I've decided to take a deeper look at threlte which is using a SvelteKit-setup.

I've replaced threlte source with svelthree source etc., but was not able to npm i inside threlte/packages folder, getting the config.kit.package has been removed — use @sveltejs/package instead error. I then tried a fresh SvelteKit-app install and have noticed the Library-option while running npm create svelte@latest my-app.

There's a link inside the fresh SvelteKit-library-project to: https://github.com/sveltejs/kit/tree/master/packages/kit

It seems that switching to SvelteKit-setup is the way to go, so let's give it a try!

@vatro vatro self-assigned this Sep 5, 2022
@vatro vatro added this to the 1.0.0-next.1 milestone Sep 5, 2022
@vatro vatro added project setup general project setup issue code quality labels Sep 5, 2022
@vatro
Copy link
Owner Author

vatro commented Sep 6, 2022

Oh, yeah, so far so good! 🥳 Finally I see light concerning a decent project setup with proper TS + ESLint etc. It's going to be much more fun developing + code quality will massively improve (after fixing all ESLint issues). 🚀

@vatro
Copy link
Owner Author

vatro commented Sep 6, 2022

IMPORTANT notices:

  • @sveltejs/package's type definitions generator (emitTypes: true) doesn't like export function foo or export async function foo: generates get undefined() and set undefined(). Those need to be rewritten to export const foo = () => {...} or export const foo = async () => {...}

  • @sveltejs/package's type definitions generator (emitTypes: true) creates types by adding Props to the component's class name, so they interfere with svelthrees *Props types. Those need to be changed to *Properties.

  • @sveltejs/package's type definitions generator doesn't allow importing and usage of three.js classes with the same name as the component itself. Currently we're just doing import { Foo } from 'three' inside Svelte components, which works (no errors), but will produce an "incomplete" d.ts file with an empty __propDef ( declare const __propDef: any; ) so all component props will be typed as any. Atm, I don't know if type definitions generation can somehow be tweaked in order for this to work.

    Solution is to import { Foo as FooDifferent } from 'three'.
    threlte also does it this way, e.g.: import { Foo as FooThree } from 'three'.

vatro pushed a commit that referenced this issue Sep 7, 2022
- add ability to iterate over manually user-created / svelthree-generated children and $destroy() them
- Refactor SvelthreeGLTF.ts accordingly

After this I'll migrate to new `SvelteKit`-library project setup (see #161), which will allow me to massively increase code quality and development speed in future. All possible errors with this refactor will be targeted after the migration.
@vatro vatro pinned this issue Sep 8, 2022
@vatro vatro changed the title Try changing to SvelteKit style project setup / publishing Switch to SvelteKit/Svelte-library style project setup / publishing Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
Update package.json
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 8, 2022
vatro pushed a commit that referenced this issue Sep 9, 2022
…161)

Also: change types `./*` import path to `../types/*`
vatro pushed a commit that referenced this issue Sep 9, 2022
vatro pushed a commit that referenced this issue Sep 9, 2022
- different components types import
- incl. several ESLint fixes
vatro pushed a commit that referenced this issue Sep 9, 2022
- `lib/utils`
- `lib/ani`
- `lib/logic`
- `Canvas`
etc.
vatro pushed a commit that referenced this issue Sep 9, 2022
…on declarations from components (#161)

`@sveltejs/package's type definitions generator doesn't like exported function declarations. `export function foo` or `export async function foo` will generate `get undefined()` and `set undefined()` accessors in components' `t.ds`.
vatro pushed a commit that referenced this issue Sep 9, 2022
vatro pushed a commit that referenced this issue Sep 9, 2022
vatro pushed a commit that referenced this issue Sep 9, 2022
will change it back later after running format.
vatro pushed a commit that referenced this issue Sep 9, 2022
vatro pushed a commit that referenced this issue Sep 9, 2022
…THREE_Foo` from 'three' instead (#161)

- I've chosen `THREE_` as prefix, may change in future, but I like it so far.
- Also: currently `Scene` and `Object3D` three.js classes and types are always being imported `as THREE_Foo`, but this is actually not always neccessary -> may change before `1.0.0-next.1`
vatro pushed a commit that referenced this issue Sep 9, 2022
…d `d.ts` has error) (#161)

Svelte type definitions generator doesn't like { [P in keyof AnyMaterialProps]: AnyMaterialProps[P] } here. Using just `AnyMaterialProps` is ok (tested)! Check also with other `*Properties`, maybe we don't need `[P in keyof ...` (see #162)
vatro pushed a commit that referenced this issue Sep 11, 2022
vatro pushed a commit that referenced this issue Sep 11, 2022
vatro pushed a commit that referenced this issue Sep 11, 2022
#161)

- Fix generic `mat` shorthand property type when using accessors:
  - Replace `mat` accessors type definitions (accessor getter and setter) -> only `Mesh` and `Points`, this will give us correct intellisense with e.g. `comp_ref.mat = {...}` depending on which material has been asigned to the `Mesh` or `Points` component.

- Optimize all accessors-jsdoc-comments:
  - Copy accessors-comments from `__propDef` to `class` definition.
  - Fix any comment-indentation issues (_only in `class` definition, leaving generated
  `__propDef` comments as they are_)
  - Add svelthree-specific accessors-hint: ◁▶ _svelthree-component accessor_
vatro pushed a commit that referenced this issue Sep 11, 2022
vatro pushed a commit that referenced this issue Sep 11, 2022
Type `Mat` to be used with a `mat` object.
vatro pushed a commit that referenced this issue Sep 11, 2022
@vatro
Copy link
Owner Author

vatro commented Sep 12, 2022

done 🥳
see 2500169

@vatro vatro closed this as completed Sep 12, 2022
@vatro vatro unpinned this issue Oct 4, 2022
@vatro vatro mentioned this issue Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality project setup general project setup issue
Projects
None yet
Development

No branches or pull requests

1 participant