-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
fix: node16 types #888
base: next
Are you sure you want to change the base?
fix: node16 types #888
Conversation
✅ Deploy Preview for tresjs-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
check #889 and merge it here if it is fine for you |
package.json
Outdated
}, | ||
"pnpm": { | ||
"overrides": { | ||
"typescript": "5.7.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to pin the version, use ^5.7.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ypu will need to run pnpm install
the lock file should be updated
Try applying this diff (save it to foo.diff in repo and run diff --git a/netlify.toml b/netlify.toml
index 247247d..4d2e490 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -1,6 +1,6 @@
[build]
publish = "docs/.vitepress/dist"
-command = "pnpm run build && pnpm docs:build"
+command = "NODE_OPTIONS=--max-old-space-size=2048 pnpm run build && pnpm docs:build"
[build.environment]
-NODE_VERSION = "18"
+NODE_VERSION = "22"
diff --git a/package.json b/package.json
index 35039ba..4ca324c 100644
--- a/package.json
+++ b/package.json
@@ -121,6 +121,9 @@
"pnpm": {
"overrides": {
"typescript": "^5.7.2"
+ },
+ "patchedDependencies": {
+ "vite-plugin-dts": "patches/vite-plugin-dts.patch"
}
},
"publishConfig": {
diff --git a/patches/vite-plugin-dts.patch b/patches/vite-plugin-dts.patch
new file mode 100644
index 0000000..2b020aa
--- /dev/null
+++ b/patches/vite-plugin-dts.patch
@@ -0,0 +1,17 @@
+diff --git a/dist/index.mjs b/dist/index.mjs
+index 3822cbc3bf4c271c6a82fe2729d8c5e15b657b0f..95892c08f197c45e6d0997f4ff71329ab6ce9041 100644
+--- a/dist/index.mjs
++++ b/dist/index.mjs
+@@ -58,10 +58,10 @@ async function runParallel(maxConcurrency, source, iteratorFn) {
+ for (const item of source) {
+ const p = Promise.resolve().then(() => iteratorFn(item, source));
+ ret.push(p);
+- if (maxConcurrency <= source.length) {
++ if (1 <= source.length) {
+ const e = p.then(() => executing.splice(executing.indexOf(e), 1));
+ executing.push(e);
+- if (executing.length >= maxConcurrency) {
++ if (executing.length >= 1) {
+ await Promise.race(executing);
+ }
+ }
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b3966a0..b8c4f7b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7,6 +7,11 @@ settings:
overrides:
typescript: ^5.7.2
+patchedDependencies:
+ vite-plugin-dts:
+ hash: kywozdv6i5i7n4adjtglj6xx5e
+ path: patches/vite-plugin-dts.patch
+
importers:
.:
@@ -35,7 +40,7 @@ importers:
version: 4.0.3(@tresjs/[email protected]([email protected])([email protected]([email protected])))(@types/[email protected])([email protected])([email protected]([email protected]))
'@tresjs/eslint-config':
specifier: ^1.4.0
- version: 1.4.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))
+ version: 1.4.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected])([email protected])
'@types/three':
specifier: ^0.171.0
version: 0.171.0
@@ -50,10 +55,10 @@ importers:
version: 5.2.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))
'@vitest/coverage-c8':
specifier: ^0.33.0
- version: 0.33.0([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))
+ version: 0.33.0([email protected])
'@vitest/coverage-v8':
specifier: ^2.1.8
- version: 2.1.8([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))
+ version: 2.1.8([email protected])
'@vitest/ui':
specifier: ^2.1.8
version: 2.1.8([email protected])
@@ -122,7 +127,7 @@ importers:
version: 0.8.0
vite-plugin-dts:
specifier: 4.4.0
- version: 4.4.0(@types/[email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))
+ version: 4.4.0(patch_hash=kywozdv6i5i7n4adjtglj6xx5e)(@types/[email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))
vite-plugin-inspect:
specifier: ^0.10.4
version: 0.10.4([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))
@@ -5627,7 +5632,7 @@ snapshots:
'@andrewbranch/[email protected]': {}
- '@antfu/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))':
+ '@antfu/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])([email protected])':
dependencies:
'@antfu/install-pkg': 0.4.1
'@clack/prompts': 0.7.0
@@ -5636,7 +5641,7 @@ snapshots:
'@stylistic/eslint-plugin': 2.12.1([email protected]([email protected]))([email protected])
'@typescript-eslint/eslint-plugin': 8.18.1(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])
'@typescript-eslint/parser': 8.18.1([email protected]([email protected]))([email protected])
- '@vitest/eslint-plugin': 1.1.20(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))
+ '@vitest/eslint-plugin': 1.1.20(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])
eslint: 9.17.0([email protected])
eslint-config-flat-gitignore: 0.3.0([email protected]([email protected]))
eslint-flat-config-utils: 0.4.0
@@ -6810,9 +6815,9 @@ snapshots:
transitivePeerDependencies:
- '@vue/composition-api'
- '@tresjs/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))':
+ '@tresjs/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected])([email protected])':
dependencies:
- '@antfu/eslint-config': 3.6.2(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))
+ '@antfu/eslint-config': 3.6.2(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))(@vue/[email protected])([email protected]([email protected]([email protected])))([email protected]([email protected]))([email protected])([email protected])
eslint: 9.17.0([email protected])
eslint-plugin-format: 0.1.3([email protected]([email protected]))
transitivePeerDependencies:
@@ -7179,7 +7184,7 @@ snapshots:
vite: 6.0.5(@types/[email protected])([email protected])([email protected])([email protected])
vue: 3.5.13([email protected])
- '@vitest/[email protected]([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))':
+ '@vitest/[email protected]([email protected])':
dependencies:
'@ampproject/remapping': 2.3.0
c8: 7.14.0
@@ -7188,7 +7193,7 @@ snapshots:
std-env: 3.8.0
vitest: 2.1.8(@types/[email protected])(@vitest/[email protected])([email protected])
- '@vitest/[email protected]([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))':
+ '@vitest/[email protected]([email protected])':
dependencies:
'@ampproject/remapping': 2.3.0
'@bcoe/v8-coverage': 0.2.3
@@ -7206,7 +7211,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@vitest/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]))':
+ '@vitest/[email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected])':
dependencies:
'@typescript-eslint/utils': 8.18.1([email protected]([email protected]))([email protected])
eslint: 9.17.0([email protected])
@@ -10957,7 +10962,7 @@ snapshots:
dependencies:
vite: 6.0.5(@types/[email protected])([email protected])([email protected])([email protected])
- [email protected](@types/[email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):
+ [email protected](patch_hash=kywozdv6i5i7n4adjtglj6xx5e)(@types/[email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):
dependencies:
'@microsoft/api-extractor': 7.48.1(@types/[email protected])
'@rollup/pluginutils': 5.1.4([email protected])
|
Hi @brc-dd thanks for jumping in! I manually added the increased space size for Netlify but I have a question regarding the diff file you provided, whats the idea behind patching "patchedDependencies": {
+ "vite-plugin-dts": "patches/vite-plugin-dts.patch"
} |
Ah, vite-plugin-dts is trying to run multiple instances of api-extractor concurrently (for each entry file) which are causing the memory issue. So with that patch I'm setting maxConcurrency to 1. With the patch the memory was not exceeding ~1.5GB locally for me (even without max-old-space-size). You can probably make a PR to vite-plugin-dts to add an option to specify concurrency. |
Ohh @brc-dd thanks for clarifying, it's something that is going to be eventually merged on the |
I mean you can try creating an issue/PR. The project is active. Ultimately, it's up to their maintainer. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Did yoy check this pr via pkg.pr.new in a reproduction?
Mmmm @brc-dd If I remove the multiple entries on vite.config.ts the types work again
|
Yeah I think this is a limitation of api-extractor. I remember seeing it in their docs that it only works if your project has single entrypoint. rollupTypes option might not work for you then 🫠 |
In that case @userquin I'm gonna remove the multiple entries and the submodules and change the target of this PR to the |
Using only 1 entry works? |
The utils.d.ts issue is because of imports like |
Quick question, does tres use something like triple slash reference to register global components? (similar to "vite/client" ?) |
BREAKING CHANGE: import submodules like `@Tresjs/core/components` will no longer be possible. Use `@Tresjs/core` instead
My original pr was also replacing all src/ imports to relative paths... |
This is weird, iirc post processing was working, the package using 2 entries |
Then how are they discovered? 👀 |
Ok so by exporting all the types that where private before fix: export all types for TresComponents, which helps build the Maybe with the new approach, all composed types need to be explicitly exported? @userquin
@brc-dd dunno how to answer that, they were just working with the export |
hmm, I think they were working because when you import something The correct way is to do this like The nuxt module correctly pushes this - https://github.com/Tresjs/nuxt/blob/f19abcb040b3b8dc7adbdd6ac98d63d4ce57bd15/src/module.ts#L54 In vite too if you add that manually it was working fine with multiple entrypoints:
diff --git a/src/composables/useRaycaster/index.ts b/src/composables/useRaycaster/index.ts
index da77950..ec2a369 100644
--- a/src/composables/useRaycaster/index.ts
+++ b/src/composables/useRaycaster/index.ts
@@ -1,5 +1,5 @@
import type { EventHook } from '@vueuse/core'
-import type { DomEvent, TresCamera, TresEvent, TresInstance } from 'src/types'
+import type { DomEvent, TresCamera, TresEvent, TresInstance } from '../../types'
import type { Intersection, Object3D, Object3DEventMap } from 'three'
import type { ShallowRef } from 'vue'
import type { TresContext } from '../useTresContextProvider'
diff --git a/src/composables/useTresEventManager/index.ts b/src/composables/useTresEventManager/index.ts
index a20f436..c84f2cf 100644
--- a/src/composables/useTresEventManager/index.ts
+++ b/src/composables/useTresEventManager/index.ts
@@ -1,4 +1,4 @@
-import type { EmitEventFn, EmitEventName, Intersection, TresEvent, TresInstance, TresObject } from 'src/types'
+import type { EmitEventFn, EmitEventName, Intersection, TresEvent, TresInstance, TresObject } from '../../types'
import type { Object3D, Object3DEventMap, Scene } from 'three'
import type { TresContext } from '../useTresContextProvider'
import { shallowRef } from 'vue'
diff --git a/src/devtools/plugin.ts b/src/devtools/plugin.ts
index 8b4ab89..f8222b0 100644
--- a/src/devtools/plugin.ts
+++ b/src/devtools/plugin.ts
@@ -188,6 +188,7 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) {
if (instance.isScene) {
payload.state.info = {
+ // @ts-expect-error FIXME
objects: instance.children.length,
memory: calculateMemoryUsage(instance),
calls: tres.renderer.value.info.render.calls,
diff --git a/src/types/index.ts b/src/types/index.ts
index 40a3918..1bf951c 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -198,10 +198,10 @@ export type TresControl = THREE.EventDispatcher & { enabled: boolean }
export type WithMathProps<P> = { [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K] }
-interface RaycastableRepresentation {
+export interface RaycastableRepresentation {
raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void
}
-type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown
+export type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown
export interface VueProps {
children?: VNode[]
@@ -217,8 +217,8 @@ export type ThreeElement<T extends ConstructorRepresentation> = Mutable<
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
>
-type ThreeExports = typeof THREE
-type ThreeInstancesImpl = {
+export type ThreeExports = typeof THREE
+export type ThreeInstancesImpl = {
[K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation
? ThreeElement<ThreeExports[K]>
: never
@@ -228,16 +228,10 @@ export interface ThreeInstances extends ThreeInstancesImpl {
primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
}
-type TresComponents = {
+export type TresComponents = {
[K in keyof ThreeInstances as `Tres${Capitalize<string & K>}`]: DefineComponent<ThreeInstances[K]>
}
declare module 'vue' {
- export interface GlobalComponents extends TresComponents { }
-}
-declare module '@vue/runtime-core' {
interface GlobalComponents extends TresComponents { }
}
-declare module '@vue/runtime-dom' {
- interface GlobalComponents extends TresComponents {}
-}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 80704a8..6293bc7 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,5 +1,5 @@
-import type { nodeOps } from 'src/core/nodeOps'
-import type { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types'
+import type { nodeOps } from '../core/nodeOps'
+import type { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from '../types'
import type { Material, Mesh, Object3D, Texture } from 'three'
import type { TresContext } from '../composables/useTresContextProvider'
import { DoubleSide, MathUtils, MeshBasicMaterial, Scene, Vector3 } from 'three'
diff --git a/src/utils/is.ts b/src/utils/is.ts
index 4e7af96..9dd66f4 100644
--- a/src/utils/is.ts
+++ b/src/utils/is.ts
@@ -1,4 +1,4 @@
-import type { TresObject, TresPrimitive } from 'src/types'
+import type { TresObject, TresPrimitive } from '../types'
import type { BufferGeometry, Camera, Fog, Light, Material, Object3D, Scene } from 'three'
export function und(u: unknown) {
diff --git a/vite.config.ts b/vite.config.ts
index 7013397..e3255c8 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -31,7 +31,6 @@ export default defineConfig({
},
}),
dts({
- insertTypesEntry: true,
rollupTypes: true,
}),
banner({
You can avoid breaking change this way. |
Dont augment |
Before:
After: