example/web-worker/worker/worker.js
importScripts('path to new bundle');
onmessage = (e) => {
const ifcData = e.data;
const loaded = IFCjs.loadIfcFileItems(ifcData);
const structured = IFCjs.constructProject(loaded);
postMessage(structured);
};
We are only using two functions. The simpliest approach is to only bundle these two functions... so, let's do that!
export { loadIfcFileItems } from './ifc-parser/ifc-services/ifc-processor.js';
export { constructProject } from './ifc-project-builder/ifc-structure-builder.js';
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()
]
}];