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.
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.
Adding @RaananW to the party
Ah, I see. But the issue is that
.js is being added to imports from directories, not only files. So it should be either
And I guess some of the latest build changes to add the .js suffix in ES6 have broken it:
Yes! That’s very interesting. I’ll fix it for the next npm release.
Thanks for reporting!
Fix submitted, next viewer release will be fixed. Thanks again!
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
This is what the line looks like in @babylonjs/viewer/index.js
And it works if I change it to:
I will fix that asap. thanks for notifying!
please try latest npm package, it should be fine now.