# How to import NodeMaterial with tree shaking?

**URL:** <https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749>\
**Category:** Questions\
**Created:** [November 16, 2022, 3:26pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749 "2022-11-16T15:26:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 16, 2022, 3:26pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/1 "2022-11-16T15:26:03Z")

</div>

Doing tree shaking I have errors with Nodematerials import.

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/0/807c1048f84141807c131ae22c591fa7e2671f88.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/3/e397f254d6f4b0bebe1d5400b20fcc25fe11c578.png)

(Of course, it works when doing `import * as BABYLON from "@babylonjs/core";`

There was the thread - [Importing NodeMaterial with tree shaking](https://forum.babylonjs.com/t/importing-nodematerial-with-tree-shaking/24828) with similar issues, but still I am not able to make it work in any import combinations which I’ve tried.

Could anybody provide the right import statement for Nodematerial?

---

<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:** [November 16, 2022, 6:03pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/2 "2022-11-16T18:03:04Z")

</div>

You probably need to import all the blocks that are usefull in your serialization for side effects.

or better import { NodeMaterial } as BABYLON from “@babylonjs/core/Materials/Node”; to have all the node mat side effects.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 16, 2022, 6:21pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/3 "2022-11-16T18:21:11Z")

</div>

In this case I have

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/8/a81e570b61dba55275a18542a13f91f90bd9a809.png)

with the next errors shown:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/5/e55f69c1ead528a78482a42a5c837217085a0ddb.png)

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/b/8b9ccb5e2d971aaaf958bc04fd8e92aa3f406111.png)

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/5/154da9310058ca9ceb0f27059ec9eb1564b63410.png)

(Babylon version 5.16.0)

---

<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:** [November 16, 2022, 6:38pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/4 "2022-11-16T18:38:17Z")

</div>

so sorry my bad with copy paste… I meant:

mport { NodeMaterial } from “@babylonjs/core/Materials/Node”

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 16, 2022, 6:42pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/5 "2022-11-16T18:42:22Z")

</div>

This one I tried already:

```auto
import { NodeMaterial } from "@babylonjs/core/Materials/Node";

```

and it gives the next error:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/f/9f696715f6b3b42aebbe9067c1e05b733ad77e17.png)

---

<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:** [November 16, 2022, 6:47pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/6 "2022-11-16T18:47:09Z")

</div>

Ohhhhh… can you provide a quick repro project so that I can dig in ?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 16, 2022, 7:17pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/7 "2022-11-16T19:17:12Z")

</div>

Will try 🙂

> [@sebavan](#):
>
> You probably need to import all the blocks that are usefull in your serialization for side effects.

How to know which blocks I need to import?

---

<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:** [November 16, 2022, 10:11pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/8 "2022-11-16T22:11:04Z")

</div>

import { NodeMaterial } from “@babylonjs/core/Materials/Node”; should import them all so it might not be this unfortunately ☹ and to know the nodes, it would be all the ones in the material you are trying to parse so kind of hard to really go deep on this front.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [December 16, 2022, 3:21pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/9 "2022-12-16T15:21:48Z")

</div>

Hey @labris how are you? 😃 Just checking in to see if you need any more help on this

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [December 16, 2022, 4:14pm UTC](https://forum.babylonjs.com/t/how-to-import-nodematerial-with-tree-shaking/35749/10 "2022-12-16T16:14:41Z")

</div>

I’ll check and let you know 🙂
