I am facing an issue with a web worker in Angular that used to function properly in the previous versions:
/// <reference lib="webworker" />
import { ParseResult } from "papaparse";
import { readCSV } from '@fireflysemantics/csv';
addEventListener('message', ({ data }) => {
const result: ParseResult<any> = readCSV(data)
postMessage(result);
});
When I comment out most of the code in the worker, it builds fine:
/// <reference lib="webworker" />
import { ParseResult } from "papaparse";
//import { readCSV } from '@fireflysemantics/csv';
addEventListener('message', ({ data }) => {
//const response = `worker response to ${data}`;
//postMessage(response);
});
However, when I uncomment the line:
import { readCSV } from '@fireflysemantics/csv';
It generates multiple errors like these:
Error: ./src/app/services/csv.worker.ts (./node_modules/worker-plugin/dist/loader.js?name=0!./src/app/services/csv.worker.ts)
Module build failed (from ./node_modules/worker-plugin/dist/loader.js):
Error: node_modules/@angular/cdk/a11y/aria-describer/aria-describer.d.ts:16:21 - error TS2304: Cannot find name 'Element'.
...
(Continued list of errors for missing names and declarations)
...
Any ideas on how to resolve this? Unfortunately, I cannot test this on Stackblitz due to web workers not being supported. Here are my current environment details:</p>
<h1>Environment</h1>
<pre><code> _ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 11.0.7
Node: 12.6.0
OS: linux x64
Angular: 11.0.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.7
@angular-devkit/build-angular 0.1100.7
@angular-devkit/core 11.0.7
@angular-devkit/schematics 11.0.7
@angular/cdk 11.2.3
@angular/cli 11.0.7
@angular/material 11.2.3
@schematics/angular 11.0.7
@schematics/update 0.1100.7
ng-packagr 11.2.4
rxjs 6.6.6
typescript 4.0.7