Tresjs / cientos

Collection of useful helpers and fully functional, ready-made abstractions for TresJS
https://cientos.tresjs.org/
MIT License
275 stars 40 forks source link

Playground: 'Internal server error: Failed to resolve import "stats.js"' #204

Closed andretchen0 closed 1 year ago

andretchen0 commented 1 year ago

Describe the bug

Playground

When I run npm run dev in ./playground, I get the following error:

11:43:29 AM [vite] Internal server error: Failed to resolve import "stats.js" from "../src/core/misc/Stats.ts". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/devusersteven/Documents/clients/me/oss/cientos/src/core/misc/Stats.ts:3:22
  1  |  import { onUnmounted, onMounted } from "vue";
  2  |  import { useRenderLoop } from "@tresjs/core";
  3  |  import StatsImpl from "stats.js";
     |                         ^
  4  |  export const stats = (showPanel = 0) => {
  5  |    const stats2 = new StatsImpl();

Calling stats()

Also, when importing and calling stats() as shown in the guide, I'm getting this error in the console:

Uncaught SyntaxError: ambiguous indirect export: stats

Reproduction link included below.


For further context, I just pulled the latest cientos changes in order to merge in some local changes.

Reproduction

https://stackblitz.com/edit/tresjs-basic-mjs229?file=src%2FApp.vue

Steps to reproduce

$ cd playground
$ npm run dev

System Info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1
    Memory: 34.77 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.5.1 - /opt/homebrew/bin/node
    npm: 9.8.0 - /opt/homebrew/bin/npm
    pnpm: 8.6.5 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 116.0.5845.179
    Safari: 16.2
  npmPackages:
    @tresjs/core: 3.1.1 => 3.1.1 
    @tresjs/leches: ^0.8.0 => 0.7.0 


### Used Package Manager

pnpm

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/Tresjs/cientos/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/Tresjs/cientos/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://cientos.tresjs.org/guide).
- [X] Check that there isn't [already an issue](https://github.com/Tresjs/cientos/issues) that reports the same bug to avoid creating a duplicate.
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
JaimeTorrealba commented 1 year ago

Hi, in the pkg we don't use npm, recently we've updated the contributions guide. But basically we encourage you to use pnpm here the link https://github.com/Tresjs/cientos/blob/main/CONTRIBUTING.md (basically, you should use pnpm playground in the root folder)

The second case: Uncaught SyntaxError: ambiguous indirect export: stats

I believe I'll do a patch for that (the first letter should be Uppercase)

andretchen0 commented 1 year ago

pnpm

Gotcha. Thanks for pointing me in the right direction.

With the previous version, I was missing the nr comand to run pnpm run playground locally from the root folder. But with the recent changes, things seem to be working. Great!


Reopening as issue is referenced here.