# Importing NodeMaterial with tree shaking

**URL:** <https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828>\
**Category:** Questions\
**Tags:** material\
**Created:** [October 26, 2021, 5:29pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828 "2021-10-26T17:29:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrieljbaker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gabrieljbaker/32/12670_2.png) [@gabrieljbaker](https://forum.babylonjs.com/u/gabrieljbaker)\
**Post date:** [October 26, 2021, 5:29pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/1 "2021-10-26T17:29:50Z")

</div>

Hi all! We are doing some tree-shaking of our babylon bundle, so doing specific imports for required classes, etc. When I import the NodeMaterial class like this

import { NodeMaterial } from “@babylonjs/core/Materials/Node/nodeMaterial”;

and then use this method:

```
      NodeMaterial.ParseFromSnippetAsync("#CA2RY8#21", RFS.scene).then(
        nodeMaterial => {
          m.material = nodeMaterial;
        }
      );

```

I get this error in console:

```
 **Uncaught (in promise) Build of NodeMaterial failed:**

```

**input vector from block worldPos[TransformBlock] is not connected and is not optional.**  
**input rgba from block FragmentOutput[FragmentOutputBlock] is not connected and is not optional.**

But when I’m using the Babylon namespace and not the specific import, there are no errors. Any ideas?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 26, 2021, 5:53pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/2 "2021-10-26T17:53:17Z")

</div>

cc @RaananW

---

<div class="post-metadata">

**Author:** ![gabrieljbaker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gabrieljbaker/32/12670_2.png) [@gabrieljbaker](https://forum.babylonjs.com/u/gabrieljbaker)\
**Post date:** [October 26, 2021, 6:56pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/3 "2021-10-26T18:56:50Z")

</div>

PS: not a full solution, but I was able to get it to work from importing from whole /Node directory rather than /Node/nodeMaterial

Wondering if I need to import that whole folder or just certain bits?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [October 27, 2021, 1:26pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/4 "2021-10-27T13:26:17Z")

</div>

Seems like we are missing some imports.  
The temporary solution to load everything from /Node would be what I would suggest until I find the time to fully analyze this 🙂

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [October 27, 2021, 1:26pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/5 "2021-10-27T13:26:21Z")

</div>



---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 19, 2021, 2:01pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/6 "2021-11-19T14:01:28Z")

</div>

Just a follow up on this one - currently there is no way around importing the entire node module when parsing, since we don’t know beforehand which blocks will be used when parsing.

I hope to address this soon with a new type of package that will be more import-on-demand-friendly.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 19, 2021, 2:01pm UTC](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828/7 "2021-11-19T14:01:30Z")

</div>


