From 4879d3482d290f05f181338f093d3dfc42ce0c80 Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 30 Jul 2026 08:27:40 +0200 Subject: [PATCH] fix(subsUnion): force-bundle turf deps used only by the worker thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Meteor's build only includes npm packages it sees imported/required somewhere in its own traced module graph. private/workers/unionWorker.js is a plain asset (loaded at runtime via new Worker(), never import/require'd from Meteor-compiled code), so @turf/circle, @turf/union and @turf/truncate got silently dropped from programs/server/node_modules — the worker crashed on every call with "Cannot find module '@turf/circle'", which incrementalAdd/process swallowed and stored as a "null" union (typeof null === 'object', so the null-check that guards against failed unions doesn't catch it). Side-effect imports here force Meteor to bundle them. --- imports/startup/server/calcUnionAsync.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/startup/server/calcUnionAsync.js b/imports/startup/server/calcUnionAsync.js index 6e00c03..0eaa57f 100644 --- a/imports/startup/server/calcUnionAsync.js +++ b/imports/startup/server/calcUnionAsync.js @@ -1,6 +1,16 @@ import path from 'path'; import { Worker } from 'worker_threads'; +// Meteor only bundles the npm packages it sees imported/required somewhere in +// its own compiled module graph. The actual usage of these three is inside +// private/workers/unionWorker.js, a plain asset file Meteor's bundler never +// traces (it's loaded at runtime via new Worker(), not import/require here). +// Without this, `meteor build` drops them from programs/server/node_modules +// and the worker fails at startup with "Cannot find module '@turf/circle'". +import '@turf/circle'; +import '@turf/union'; +import '@turf/truncate'; + const WORKER_PATH = path.resolve(process.cwd(), 'assets/app/workers/unionWorker.js'); /**