dev@236: /** dev@236: * Created by lucas on 01/12/2016. dev@236: */ dev@236: dev@236: /* This is a really ad-hoc and crappy way of re-exporting modules, dev@236: * whilst trying to reduce global namespace pollution dev@236: * The main use case is providing access to npm modules inside a worker via importScripts dev@236: * over using some compiled version (a la *.min.js, *.umd.js etc) dev@236: * a better solution would be a custom webpack bundle, dev@236: * but the current build system in angular-cli doesn't provide a way for custom webpack bundles dev@236: * ....unless I am missing something dev@236: * dev@236: * this does, however, mean that modules will be loaded twice.. dev@236: * once by index.html and once by the worker.. dev@236: * one could potentially run a custom post build script dev@236: * to remove the script tag in index.html generated by angular-cli for scripts.bundle dev@236: * .. or find another way of doing this entirely.... dev@236: */ dev@236: dev@236: import extractionWorker from './app/services/feature-extraction/FeatureExtractionWorker'; dev@236: dev@236: const modules = { dev@236: 'feature-extraction-worker': extractionWorker dev@236: }; dev@236: dev@236: if (typeof (self as any).importScripts === 'function' /* in a worker */) { dev@236: dev@236: self['require'] = (moduleName) => { dev@236: if (modules.hasOwnProperty(moduleName)) { dev@236: return modules[moduleName]; dev@236: } else { dev@236: throw new Error(`Cannot find module '${moduleName}'`); dev@236: } dev@236: }; dev@236: }