mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.91k stars 35.39k forks source link

three0.167.1 vite build bug #29054

Closed flowers-10 closed 3 months ago

flowers-10 commented 3 months ago

Description

I have no issues using version 0.166.0.

0.167.1: yarn run build yarn run v1.22.19 $ vue-tsc && vite build node_modules/@types/three/examples/jsm/loaders/KTX2Loader.d.ts:2:42 - error TS2307: Cannot find module 'three/webgpu' or its corresponding type declarations. There are types at '/Users/channel1/Desktop/Project/DigitalTwin/node_modules/@types/three/build/three.webgpu.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

2 import { Renderer, WebGPURenderer } from "three/webgpu"; error Command failed with exit code 2.

Reproduction steps

1.version: "@types/three": "^0.167.1","three": "^0.167.1", 2.yarn run build 3.error Command failed with exit code 2.

Code

// code goes here

Live example

Screenshots

439126896

Version

r167.1

Device

No response

Browser

No response

OS

No response

Mugen87 commented 3 months ago

Do you mind trying it with this Vite configuration: https://github.com/mrdoob/three.js/pull/28650#issuecomment-2198568721

donmccurdy commented 3 months ago

I think imports from three/webgpu may need to be avoided somehow here:

https://github.com/three-types/three-ts-types/blob/master/types/three/examples/jsm/loaders/KTX2Loader.d.ts

Mugen87 commented 3 months ago

/ping @Methuselah96

Methuselah96 commented 3 months ago

It sounds like you probably have moduleResolution set to either node/node10 in your tsconfig.json (implicitly or explicitly) which should no longer be used. See this guide for advice on how to configure TypeScript to resolve this.

See https://github.com/three-types/three-ts-types/issues/1136 for more info and/or to discuss further.

Mugen87 commented 3 months ago

Merging this issue into https://github.com/three-types/three-ts-types/issues/1136.

ydmingg commented 1 month ago
// tsconfig.json
import { defineConfig } from 'vite';

{
    "compilerOptions": {
        "paths": {
            "three/webgpu": ["./node_modules/three/build/three.webgpu.min.js"]

        },
    }
}