jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.31k stars 455 forks source link

[Bug] Unable to import the `two.js/extras/jsm/zui.js` module properly within a TS project. (v8.3 and above) #630

Closed Xample closed 2 years ago

Xample commented 2 years ago

Describe the bug

Error: Module not found: Error: Can't resolve 'two.js/extras/jsm/zui.js' in .../project/path...

Something seems to be wrong with the types.d.ts

To Reproduce Steps to reproduce the behavior:

  1. npm install -g @angular/cli
  2. download this git gist, then cd within the folder containing the package.json file:
  3. ng serve
  4. Boom error

Expected behavior The app to compile properly

Screenshots

Environment (please select one):

Desktop (please complete the following information):

Additional context Here is what I've noticed:

jonobr1 commented 2 years ago

I'll take a look. In the meantime have you tried importing like this:

import { ZUI } from 'two.js/extras/jam/zui.js';
jonobr1 commented 2 years ago

Looks like TypeScript only supports the package.json custom exports property > 4.7.0 which is still in beta. See this thread. I'll remove the custom exports for now.

jonobr1 commented 2 years ago

You should be able to use the latest npm v0.8.7 as described in your gist.

Xample commented 2 years ago

good job, I bumped to 0.8.7 and the error is gone, thank you. Regarding TS 4.7, I tried using the beta to see if it solved the issue but did not. Either it's too early, or the dependence needs to be exposed in a different way. Let's keep an eye after the official release.