Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I built a test that walks the shipped import graph: the missing module that bricked Ankita 2.7.0

Description and use

A test was built to walk the shipped import graph, ensuring all relative imports are included in the ASAR, preventing runtime module‑not‑found errors.

Problem

After shipping Ankita v2.7.0, the desktop app failed to start due to an ERR_MODULE_NOT_FOUND for a missing module in the ASAR package.

Outcome

The test prevented future packaging regressions by detecting missing modules before release, ensuring the ASAR contains all required files.

Workflow

  • Load electron‑builder.yml and build a file matcher from app‑builder‑lib.
  • Enumerate all .mjs/.js/.cjs/.mts/.json files under source trees that contribute shipped code.
  • Filter files using the matcher to get the exact set that will be packaged.
  • Scan each packaged file for literal relative import statements using regexes.
  • Resolve each import specifier against the importing file’s directory. If the target exists on disk but is not in the packaged set, record it as missing.
  • Assert that the missing map is empty; if not, fail the test with the list of missing modules and importers.

Evidence

The main process died with ERR_MODULE_NOT_FOUND for desktop/chatgpt-companion/sign-in.mjs.

Source

The packaging config listed desktop/electron/**/* and desktop/browser-helper/**/*, but not desktop/chatgpt-companion/**/*.

Source

The new test lives in test/desktop/chatgpt-package.test.mjs, named every local module imported by packaged sources ships inside the ASAR file set.

Source

  • Record date: 2026-10-26T11:26:08.618Z