# Some solved problems while treeshaking

**URL:** <https://forum.babylonjs.com/t/some-solved-problems-while-treeshaking/46329>\
**Category:** Tutorials and tips\
**Tags:** treeshaking\
**Created:** [December 11, 2023, 11:33am UTC](https://forum.babylonjs.com/t/some-solved-problems-while-treeshaking/46329 "2023-12-11T11:33:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChirodSummerset](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chirodsummerset/32/31270_2.png) [@ChirodSummerset](https://forum.babylonjs.com/u/ChirodSummerset)\
**Post date:** [December 11, 2023, 11:33am UTC](https://forum.babylonjs.com/t/some-solved-problems-while-treeshaking/46329/1 "2023-12-11T11:33:06Z")

</div>

Hi.  
I was trying treeshaking today according to [this doc](https://doc.babylonjs.com/setup/frameworkPackages/es6Support#tree-shaking) and met some errors in the console. Yet I found ways to solve them.

while the doc itself haven’t listed such bugs, here I post them and the solutions here because I think they might be very common.

```auto
import { Engine } from "@babylonjs/core/Engines/engine"; 
// would cause engine to miss RegisterView method. SOLUTION:
import { Engine } from "@babylonjs/core/Engines/engine"; 
import "@babylonjs/core/Engines/Extensions/engine.views";

```

```auto
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
// console error "need to import shadowGeneratorSceneComponent" or something. SOLUTION:
import '@babylonjs/core/Lights/Shadows/shadowGeneratorSceneComponent';
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';

```

```auto
import { NodeMaterial } from '@babylonjs/core/Materials/Node/nodeMaterial';
// console error "XXX block is missing input YYY and is necessary". SOLUTION:
import { NodeMaterial } from '@babylonjs/core/Materials/Node';

// and I found another solution:
import { NodeMaterial } from '@babylonjs/core/Materials/Node/nodeMaterial';
import '@babylonjs/core/Materials/Node/Blocks';

```

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 11, 2023, 8:12pm UTC](https://forum.babylonjs.com/t/some-solved-problems-while-treeshaking/46329/2 "2023-12-11T20:12:34Z")

</div>

The First one should be the following I believe:

```auto
import { Engine } from "@babylonjs/core/Engines/engine"; 
import "@babylonjs/core/Engines/Extensions/engine.views";

```

About the third your solution will do all the nodes but you might as well limit to only the node you use 🙂

---

<div class="post-metadata">

**Author:** ![ChirodSummerset](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chirodsummerset/32/31270_2.png) [@ChirodSummerset](https://forum.babylonjs.com/u/ChirodSummerset)\
**Post date:** [December 12, 2023, 1:47am UTC](https://forum.babylonjs.com/t/some-solved-problems-while-treeshaking/46329/3 "2023-12-12T01:47:49Z")

</div>

thank you, I edited your answer into the first solution.

for the third one, if I only import NodeMaterial from `.../Materials/Node/nodeMaterial`, it throws an error like this:

```plaintext
Build of NodeMaterial failed:
input rgba from block FragmentOutput[FragmentOutputBlock] is not connected and is not optional.

```

## update

well I looked into the `Materials/Node/Index.js` and tried each of the import, the missing part I needed is `Materials/Node/Blocks`, I’ll edit into the main post 🙂
