> For the complete documentation index, see [llms.txt](https://bimwhale.gitbook.io/ifc-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bimwhale.gitbook.io/ifc-js/developer-guide/step-by-step/build-a-web-worker-bundle.md).

# Build a Web Worker Bundle

Beacuase we cannot use [Three.js](https://threejs.org) inside a `Web Worker`, we need a specific bundle/build. Let's look at the Web Worker again.

{% code title="example/web-worker/worker/worker.js" %}

```javascript
importScripts('path to new bundle');
onmessage = (e) => {
    const ifcData = e.data;
    
    const loaded = IFCjs.loadIfcFileItems(ifcData);
    const structured = IFCjs.constructProject(loaded);
    
    postMessage(structured);
};
```

{% endcode %}

We are only using two functions. The simpliest approach is to only bundle these two functions... so, let's do that!

Let's create a new `src` file. We can call this `IFC.worker.js`.

{% code title="src/IFC.worker.js" %}

```javascript
export { loadIfcFileItems } from './ifc-parser/ifc-services/ifc-processor.js';
export { constructProject } from './ifc-project-builder/ifc-structure-builder.js';
```

{% endcode %}

Now, let's update the [Rollup](https://rollupjs.org/guide/en/) config file. Please note that you can have multiple bundles. In this example, we have removed the orignal bundle.&#x20;

```javascript
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';

export default [{
    input: './src/IFC.worker.js',
    external: ['chevrotain'],
    output: [{
            file: './build/IFC.worker.module.js',
            format: 'es',
            globals: {
                chevrotain: 'chevrotain'
            }
        },
        {
            file: './build/IFC.worker.js',
            format: 'iife',
            name: 'IFCjs',
            globals: {
                chevrotain: 'chevrotain'
            }
        }
    ],
    plugins: [
        babel({
            exclude: ['node_modules/**', 'libs/**', 'examples/**'],
            babelHelpers: 'bundled'
        }),
        resolve(),
        commonjs()
    ]
}];
```
