#14514·meteor

meteor test --full-app fails to find mainModule because METEOR_IGNORE patterns are applied per-directory

Author: miamaganaCreated Jul 1, 2026Updated Sep 28, 2026
LabelsProject:ToolProject:TestingType:Bugmodern-build-stack

Related to #14055 but distinct.

Versions

Summary

meteor test --full-app fails with:

=> Build failed:
   While building the application:
   error: Could not find mainModule for 'os' architecture:
   _build/test/server-meteor.js

I originally thought this needed both mainModule.server and testModule.server. That framing is wrong. It reproduces with just --full-app and a root test/ directory, whether one module or two is declared. meteor run is unaffected.

Expected behavior

meteor test --full-app builds successfully.

Actual behavior

The build fails with the "Could not find mainModule" error above.

Root cause

It's the ignore engine, not rspack. METEOR_IGNORE env patterns are applied rebased at every directory during _findSources, instead of anchored at the app root.

In --full-app mode rspack remaps the os mainModule to the generated test bundle (_build/test/server-meteor.js) and emits test/** into METEOR_IGNORE to ignore the root test/ source dir. Because the ignore matcher is re-evaluated relative to each directory, when the scan is inside _build/ the pattern test/** also matches _build/test/** and silently drops the whole generated test dir. So _findSources never returns the remapped mainModule, missingMainModule stays true, and the build errors.

I instrumented _findSources for the os arch. It returns only _build/main-dev/* and drops every _build/test/* file, even though the file is on disk and isn't matched by the ignore list when checked from the app root. The bug is the per-directory rebasing (tools/fs/optimistic and tools/isobuild/package-source).

Reproduction

https://github.com/miamagana/meteor-rspack-fullapp-repro

meteor npm install
meteor npm test

(also reproduces after removing testModule.server, leaving only mainModule.server)

Workaround

Rename the root test/ dir to anything that doesn't collide with rspack's build-context subdir (_build/test), for example app-tests/, and update meteor.testModule accordingly. That removes test/** from the ignore set and the bundle is found.

Proper fix

Apply METEOR_IGNORE env patterns once, anchored at sourceRoot, rather than rebased per directory. Standard gitignore semantics from a single root matcher already give the right behavior. Slashless patterns still match at any depth, slashed patterns like test/** match root-level only. Happy to send a PR if that direction sounds right.