There’s apparently something wrong with @babylonsjs/viewer, alpha58. This is easy to reproduce with GitHub - shamsail/babylonjsviewer (with package.json altered to get babylon’s latest alpha version):
yarn run serve
....
These dependencies were not found:
* @babylonjs/core.js in ./node_modules/@babylonjs/viewer/index.js
* @babylonjs/loaders.js in ./node_modules/@babylonjs/viewer/index.js
To install them, you can run: npm install --save @babylonjs/core.js @babylonjs/loaders.js
Taking a look at node_modules/@babylonjs/viewer/index.js these are the offending lines:
import * as BABYLON from '@babylonjs/core.js';
// load needed modules.
import '@babylonjs/loaders.js';
But even manually removing .js other errors show up. Apparently .js is being automatically appended to imports where it shouldn’t be.
The .js extensions are needed on imports that are files - if you don’t do so then webpack 5 ends up complaining if you don’t specify extensions when the NPM is a module (ie: type: ‘module’ in package.json). Looks like an issue in build script though… likely @RaananW knows what’s going on there.
Ah, I see. But the issue is that .js is being added to imports from directories, not only files. So it should be either @babylonjs/loaders or @babylonjs/loaders/index.js.
I am having trouble building with vite and rollup (sveltekit) and the mentioned lines seem to be the problem. Using “@babylonjs/viewer”: “^5.5.0”
The build fails with this:
[vite]: Rollup failed to resolve import "@babylonjs/loaders/.js" from "node_modules/@babylonjs/viewer/index.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
This is what the line looks like in @babylonjs/viewer/index.js