Easy import handling of loaders


I got a new laptop where I wanted to run my librabry GitHub - Myrmod/svelte-babylon on it. For some reason though babylonjs-loaders is not being applied on it. The exact same code on my other devices works without a problem.

So my question is, what can I do to prevent this error:

BJS - [10:08:25]: Unable to find a plugin to load .glb files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type

Can I make a change to the package to make it better installable? I use vitejs as bundler/devtool and added this to its config:

optimizeDeps: {
      include: ['babylonjs-loaders/babylonjs.loaders'],


To make it work using vitebooks’ I have to import babylonjs-loaders npm package this way:

  import 'babylonjs-loaders'
  import 'babylonjs-loaders/babylonjs.loaders'

It’s obviously a bug in vitebooks cache handling, but it might be something that library authors can catch.

I personally would like to have the possibility to import a loader plugin kinda like with the PhysicsEngine:

import * as cannon from 'cannon'
export let physicsPlugin: BABYLON.AmmoJSPlugin | BABYLON.CannonJSPlugin | BABYLON.OimoJSPlugin = new BABYLON.CannonJSPlugin(true, 10, cannon)

cc @RaananW for our next release but yup not sure we can do a lot here.

I will look into that! as I am slightly changing the way we build our packages. it seems like you are loading the actual .js file and not the package’s main file, but I wonder why this happens.

I am assigning myself and will load the repository to understand why this happens. I hope it is a simple change to our package.json file.

1 Like

If I can help you with anything, just let me know :slight_smile:

1 Like


Finally got a chance to open the project, but I get the following errors when running it:

PS C:\Users\raweber\Documents\GitHub\svelte-babylon> npm run dev -- --open

> svelte-babylon@0.11.0 dev
> svelte-kit dev "--open"

> ENOENT: no such file or directory, scandir 'C:\Users\raweber\Documents\GitHub\svelte-babylon\src\routes'
Error: ENOENT: no such file or directory, scandir 'C:\Users\raweber\Documents\GitHub\svelte-babylon\src\routes'
    at Object.readdirSync (node:fs:1392:3)
    at walk (file:///C:/Users/raweber/Documents/GitHub/svelte-babylon/node_modules/@sveltejs/kit/dist/chunks/index2.js:448:15)
    at create_manifest_data (file:///C:/Users/raweber/Documents/GitHub/svelte-babylon/node_modules/@sveltejs/kit/dist/chunks/index2.js:635:2)
    at update_manifest (file:///C:/Users/raweber/Documents/GitHub/svelte-babylon/node_modules/@sveltejs/kit/dist/chunks/index.js:4221:27)
    at Object.configureServer (file:///C:/Users/raweber/Documents/GitHub/svelte-babylon/node_modules/@sveltejs/kit/dist/chunks/index.js:4305:4)
    at Object.createServer (C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\vite\dist\node\chunks\dep-76613303.js:60468:41)
    at async dev (file:///C:/Users/raweber/Documents/GitHub/svelte-babylon/node_modules/@sveltejs/kit/dist/chunks/index.js:4634:17)
    at async file:///C:/Users/raweber/Documents/GitHub/svelte-babylon/node_modules/@sveltejs/kit/dist/cli.js:908:44
PS C:\Users\raweber\Documents\GitHub\svelte-babylon> npm run vitebook:dev 

> svelte-babylon@0.11.0 vitebook:dev
> vitebook dev

 > error: The entry point "C:/Users/raweber/Documents/GitHub/svelte-babylon/.vitebook/config.js" cannot be marked as external

 Error: Build failed with 1 error:
error: The entry point "C:/Users/raweber/Documents/GitHub/svelte-babylon/.vitebook/config.js" cannot be marked as external
    at failureErrorWithLog (C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:1475:15)
    at C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:1133:28
    at runOnEndCallbacks (C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:923:63)
    at buildResponseToResult (C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:1131:7)
    at C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:1240:14
    at C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:611:9
    at handleIncomingPacket (C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:708:9)
    at Socket.readFromStdout (C:\Users\raweber\Documents\GitHub\svelte-babylon\node_modules\@vitebook\core\node_modules\esbuild\lib\main.js:578:7)
    at Socket.emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:315:12) {
  errors: [
      detail: undefined,
      location: null,
      notes: [],
      pluginName: '',
      text: 'The entry point "C:/Users/raweber/Documents/GitHub/svelte-babylon/.vitebook/config.js" cannot be marked as external'
  warnings: []

Anything I need to do?

Using node version 17.7

These commands are working

git clone git@github.com:Myrmod/svelte-babylon.git
cd svelte-babylon
npm ci
npm run vitebook:dev

It seems like you’re working on windows. I work in WSL2, will test it on windows

It seems like a windows issue. Thanks for pointing this out. I will try to fix it asap

I opened an issue at Error on windows 11 with powershell and node17.7 · Issue #60 · vitebook/vitebook · GitHub

Don’t forget to let me know when I can test again :slight_smile:
Oh, and check if the new version maybe solves it? 5.0.3 was released yesterday

I will let you know as soon as I get an update. Sorry for the difficulties, yesterday I prepared vitebook locally to debug it myself. Might make things faster.

Thank you :slight_smile:

1 Like

@RaananW with reworking the imports from babylonjs to @babylonjs/core etc. It now works as expected.

So the problem has essentially solved itself.

Thank you for your patience with me :slight_smile: