@@ -3,6 +3,7 @@ import type { Plugin, TransformResult, PluginContext } from 'rollup';
33import { bundleOutput } from './bundle-output' ;
44import { normalizeFsPath , hasError } from '@utils' ;
55import { optimizeModule } from '../optimize/optimize-module' ;
6+ import { STENCIL_INTERNAL_ID } from './entry-alias-ids' ;
67
78export const workerPlugin = ( config : d . Config , compilerCtx : d . CompilerCtx , buildCtx : d . BuildCtx , platform : string , inlineWorkers : boolean ) : Plugin => {
89 if ( platform === 'worker' || platform === 'hydrate' ) {
@@ -248,7 +249,6 @@ addEventListener('message', async ({data}) => {
248249
249250 } catch (e) {
250251 value = null;
251- ${ isDev ? 'console.error("Error when calling worker routine", e);' : '' }
252252 if (e instanceof Error) {
253253 err = {
254254 isError: true,
@@ -279,6 +279,8 @@ addEventListener('message', async ({data}) => {
279279` ;
280280
281281export const WORKER_HELPERS = `
282+ import { consoleError } from '${ STENCIL_INTERNAL_ID } ';
283+
282284let pendingIds = 0;
283285let callbackIds = 0;
284286const pending = new Map();
@@ -299,10 +301,12 @@ export const createWorker = (workerPath, workerName, workerMsgId) => {
299301 pending.delete(id);
300302
301303 if (err) {
302- reject( (err.isError)
304+ const errObj = (err.isError)
303305 ? Object.assign(new Error(err.value.message), err.value)
304- : err.value
305- );
306+ : err.value;
307+
308+ consoleError(errObj);
309+ reject(errObj);
306310 } else {
307311 if (callbackIds) {
308312 callbackIds.forEach(id => callbacks.delete(id));
@@ -313,7 +317,7 @@ export const createWorker = (workerPath, workerName, workerMsgId) => {
313317 try {
314318 callbacks.get(id)(...value);
315319 } catch (e) {
316- console.error (e);
320+ consoleError (e);
317321 }
318322 }
319323 }
0 commit comments