Build:es6 not working (6.43.0)

Hello!

I am trying to build es6 modules from Babylon source, but this build command seems not to work.

I have done:

  1. Cloned repo of latest version (6.43.0)
  2. I run the npm install at it is done all properly
  3. I run npm run build:umd - that worked good

But when I run
4. npm run build:es6
I got next errors:

Babylon.js> npm run build:es6

> @babylonjs/root@1.0.0 build:es6
> nx run-many --target=build --parallel --maxParallel=6 --projects=core,gui,loaders,materials,serializers,post-processes,procedural-textures,node-editor,node-geometry-editor,inspector,gui-editor,viewer,shared-ui-components,accessibility


    √  nx run @dev/build-tools:build (3s)
    √  nx run babylonjs-viewer-assets:build (5s)
    √  nx run @dev/core:build (22s)
    √  nx run @dev/serializers:build (5s)
    √  nx run @dev/gui:build (9s)
    √  nx run @dev/post-processes:build (10s)
    √  nx run @dev/procedural-textures:build (5s)
    √  nx run @lts/core:build (10s)
    √  nx run @dev/materials:build (11s)
    √  nx run @dev/loaders:build (11s)
    √  nx run @lts/serializers:build (10s)
    √  nx run @lts/gui:build (10s)
    √  nx run @lts/materials:build (10s)
    √  nx run @lts/loaders:build (10s)
    √  nx run @dev/shared-ui-components:build (18s)
    √  nx run @lts/post-processes:build (10s)
    √  nx run @lts/procedural-textures:build (10s)
    √  nx run @tools/accessibility:build (15s)
    √  nx run shared-ui-components:build (16s)
    √  nx run @tools/gui-editor:build (14s)
    √  nx run @tools/node-editor:build (12s)
    √  nx run @tools/node-geometry-editor:build (12s)

    Γ—  nx run core:build
       > @babylonjs/core@6.42.0 build
> npm run clean && npm run compile


> @babylonjs/core@6.42.0 clean
> rimraf dist && rimraf *.tsbuildinfo && rimraf "./**/*.!(cmd|md|json|build.json|lts.json|cjs)"


> @babylonjs/core@6.42.0 compile
> tsc -b tsconfig.build.json && tsc -b tsconfig.lts.json


> @babylonjs/core@6.42.0 postcompile
> build-tools -c declarations-es6 -r ../../../dev/core/src/LibDeclarations -atf ./Engines/engine.d.ts && build-tools -c add-js-to-es6 && build-tools -c prepare-es6-build -cf Engines/constants.js

Babylon.js build tools
Command: declarations-es6
Declarations ES6: root: ../../../dev/core/src/LibDeclarations append to file: ./Engines/engine.d.ts
Babylon.js build tools
Command: add-js-to-es6
No path specified, using default: ./**/*.js
Adding .js extensions to files in ./**/*.js
./BakedVertexAnimation/bakedVertexAnimationManager.js D:\viewers\babylonjs\src\tslib.es6.js
D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:26
                       throw new Error(`File ${match[1]} does not exist. Are you importing from an index/directory?`);
                       ^

       Error: File ../../../../../../tslib.es6.js does not exist. Are you importing from an index/directory?
           at D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:26:23
           at Array.forEach (<anonymous>)
           at addJsExtensionsToCompiledFiles (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:17:11)
           at addJsExtensionsToCompiledFilesCommand (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:42:9)
           at runCommand (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\index.js:34:85)
           at Object.<anonymous> (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\index.js:25:1)
           at Module._compile (node:internal/modules/cjs/loader:1376:14)
           at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
           at Module.load (node:internal/modules/cjs/loader:1207:32)
           at Module._load (node:internal/modules/cjs/loader:1023:12)

       Node.js v20.10.0
       npm ERR! Lifecycle script `compile` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @babylonjs/core@6.42.0
npm ERR!   at location: D:\viewers\babylonjs\src\Babylon.js\packages\public\@babylonjs\core
npm ERR! Lifecycle script `build` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @babylonjs/core@6.42.0
npm ERR!   at location: D:\viewers\babylonjs\src\Babylon.js\packages\public\@babylonjs\core

    √  nx run @dev/inspector:build (14s)

 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

 >  NX   Ran target build for 14 projects and 22 tasks they depend on (1m)

    √    23/24 succeeded [0 read from cache]

    Γ—    1/24 targets failed, including the following:
         - nx run core:build

How to fix that?

I didn’t have any errors, the build was successful. Try to run "build:dev or build:source:lts first, probably it may help :slight_smile:

It did not. You can check the log below - the two commands you mentioned work well. The problem is only with β€œnpx nx build core”.

And the problem is that the build system searches for …/…/…/…/…/…/tslib.es6.js, and it is outside of the Babylon source folder…

Under Linux, there are no such problems; on Windows 11, it is present; on Mac, there is another problem step before - the build script generates a binary file β€œ.bin/build-tools” and does not mark it executable, so MacOS prevents the next steps…

PS D:\viewers\babylonjs\src\Babylon.js> npm run build:source:lts

> @babylonjs/root@1.0.0 build:source:lts
> npx nx run-many --target=compile --projects=@lts/core,@lts/gui,@lts/loaders,@lts/materials,@lts/post-processes,@lts/procedural-textures,@lts/serializers --parallel=1


    √  nx run @lts/core:compile (2s)
    √  nx run @lts/gui:compile (2s)
    √  nx run @lts/loaders:compile (2s)
    √  nx run @lts/serializers:compile (2s)
    √  nx run @lts/materials:compile (2s)
    √  nx run @lts/post-processes:compile (2s)
    √  nx run @lts/procedural-textures:compile (2s)

 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

 >  NX   Successfully ran target compile for 7 projects (13s)

PS D:\viewers\babylonjs\src\Babylon.js> npm run build:dev

> @babylonjs/root@1.0.0 build:dev
> npm run build:assets && npm run build:source && npm run build:declaration -w @tools/babylon-server


> @babylonjs/root@1.0.0 build:assets
> build-tools -c pa --global

Babylon.js build tools
Command: pa
Processing assets from ./packages/**/*/src/**/*.+(png|jpg|jpeg|gif|svg|scss|css|html|json|fx)

> @babylonjs/root@1.0.0 build:source
> tsc -b ./tsconfig.devpackages.json


> @tools/babylon-server@1.0.0 build:declaration
> build-tools -c pud --config ./declarationConfigDev.json

Babylon.js build tools
Command: pud
 IPhysicsEnginePlugin as IPhysicsEnginePluginV1
 IPhysicsEnginePlugin as IPhysicsEnginePluginV1
 IPhysicsEnginePlugin as IPhysicsEnginePluginV1
aliasing  PhysicsEngine as PhysicsEngineV2
aliasing  TouchHolographicButton as TouchHolographicButtonV3
 IGLTFLoaderExtension as IGLTFBaseLoaderExtension
PS D:\viewers\babylonjs\src\Babylon.js> npx nx build core

   √    3/3 dependent project tasks succeeded [1 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”


> nx run core:build

> @babylonjs/core@6.42.0 build
> npm run clean && npm run compile
> @babylonjs/core@6.42.0 clean
> rimraf dist && rimraf *.tsbuildinfo && rimraf "./**/*.!(cmd|md|json|build.json|lts.json|cjs)"
> @babylonjs/core@6.42.0 compile
> tsc -b tsconfig.build.json && tsc -b tsconfig.lts.json
> @babylonjs/core@6.42.0 postcompile
> build-tools -c declarations-es6 -r ../../../dev/core/src/LibDeclarations -atf ./Engines/engine.d.ts && build-tools -c add-js-to-es6 && build-tools -c prepare-es6-build -cf Engines/constants.js
Babylon.js build tools
Command: declarations-es6
Declarations ES6: root: ../../../dev/core/src/LibDeclarations append to file: ./Engines/engine.d.ts
Babylon.js build tools
Command: add-js-to-es6
No path specified, using default: ./**/*.js
Adding .js extensions to files in ./**/*.js
./BakedVertexAnimation/bakedVertexAnimationManager.js D:\viewers\babylonjs\src\tslib.es6.js
D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:26
                throw new Error(`File ${match[1]} does not exist. Are you importing from an index/directory?`);
                ^
Error: File ../../../../../../tslib.es6.js does not exist. Are you importing from an index/directory?
    at D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:26:23
    at Array.forEach (<anonymous>)
    at addJsExtensionsToCompiledFiles (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:17:11)
    at addJsExtensionsToCompiledFilesCommand (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\addJSToCompiledFiles.js:42:9)
    at runCommand (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\index.js:34:85)
    at Object.<anonymous> (D:\viewers\babylonjs\src\Babylon.js\packages\dev\buildTools\dist\index.js:25:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
Node.js v20.10.0
npm ERR! Lifecycle script `compile` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @babylonjs/core@6.42.0
npm ERR!   at location: D:\viewers\babylonjs\src\Babylon.js\packages\public\@babylonjs\core
npm ERR! Lifecycle script `build` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: @babylonjs/core@6.42.0
npm ERR!   at location: D:\viewers\babylonjs\src\Babylon.js\packages\public\@babylonjs\core

 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

 >  NX   Ran target build for project core and 3 task(s) they depend on (55s)

    Γ—    1/4 failed
    √    3/4 succeeded [1 read from cache]

PS D:\viewers\babylonjs\src\Babylon.js>

I found the issue, node found some modules already installed in the top level folders outside babylon source folder, and node decide that it is okay…

2 Likes