---
id: 12297
title: 'Webpack build broken: src/worker/Data.mjs lazy-import glob bundles test/ specs (pulls @playwright/test → node-only modules)'
state: CLOSED
labels:
  - bug
  - build
assignees:
  - neo-opus-ada
createdAt: '2026-06-01T09:00:41Z'
updatedAt: '2026-06-01T10:18:33Z'
githubUrl: 'https://github.com/neomjs/neo/issues/12297'
author: neo-opus-ada
commentsCount: 0
parentIssue: null
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking: []
closedAt: '2026-06-01T10:18:33Z'
---
# Webpack build broken: src/worker/Data.mjs lazy-import glob bundles test/ specs (pulls @playwright/test → node-only modules)

## Severity: build-breaking (dev)

`npm run build-all` fails — webpack tries to bundle `@playwright/test` (and its node-only deps `path`, `chromium-bidi`) into the browser Data-worker bundle.

## Root cause

`src/worker/Data.mjs` `createInstance` does a lazy dynamic `import()` with:
- `webpackInclude: /(?:apps|docs\/app|examples|src\/data)\/.*\.mjs$/`
- `webpackExclude: /(?:\/|\\)(buildScripts|dist|node_modules…|ai…|\.claude…|server\.mjs|devindex…)/`

The exclude does **not** cover `test/`. Unit specs live at `test/playwright/unit/apps/portal/...` (canonical mirror path), whose `apps/...Component.spec.mjs` tail matches the `apps/.*\.mjs$` include. Those specs `import {test} from '@playwright/test'` → webpack pulls playwright-core (node-only) into the browser bundle → `Can't resolve 'path' / 'chromium-bidi/...'`.

This was **latent** until the first unit specs mirrored an `apps/` path — `test/playwright/unit/apps/portal/view/news/{discussions,pulls}/Component.spec.mjs` (#12288 + #12213) are the first two, so they triggered it.

## The fix

Add a `test/` segment to the `webpackExclude` so the lazy app-module loader never bundles the test tree (test specs must never enter the app bundle). One-line regex change; no spec relocation (the canonical `test/playwright/unit/<mirror>` placement is correct).

## Acceptance Criteria

- [ ] `npm run build-all` succeeds with the portal unit specs present in `test/playwright/unit/apps/`.
- [ ] No `@playwright/test` / `path` / `chromium-bidi` resolution errors in the Data-worker bundle.

## Timeline

- 2026-06-01T09:00:42Z @neo-opus-ada assigned to @neo-opus-ada
- 2026-06-01T09:00:42Z @neo-opus-ada added the `bug` label
- 2026-06-01T09:00:43Z @neo-opus-ada added the `build` label
- 2026-06-01T09:05:29Z @neo-opus-ada cross-referenced by PR #12298
- 2026-06-01T10:09:15Z @neo-opus-ada referenced in commit `112dc5a` - "fix(build): exclude test/ from App/Canvas/Task worker lazy-import globs too (#12297)

#12298 fixed only Data.mjs, but the same webpackInclude (/(?:apps|examples|...)/...) + webpackExclude
magic comments live in the App, Canvas (x2), and Task worker realms too — any test spec under an
apps/-matching path could be bundled into those browser worker bundles, pulling node-only deps. Add
test/ to every worker's webpackExclude so no realm bundles the test tree. Verified: build-threads -t
all -n → all worker bundles compiled successfully, 0 chromium-bidi/path/resolve errors. (VDom, Main,
Service workers carry no such magic comments; build scripts none.)"
- 2026-06-01T10:18:33Z @tobiu referenced in commit `d5c1f46` - "fix(build): exclude test/ from Data worker lazy-import glob to unbreak webpack (#12297) (#12298)

* fix(build): exclude test/ from Data worker lazy-import glob to unbreak webpack (#12297)

The createInstance lazy dynamic import in src/worker/Data.mjs uses webpackInclude
/(?:apps|docs/app|examples|src/data)/.*.mjs$/ which matches unit specs at
test/playwright/unit/apps/portal/... (canonical mirror path). Those specs import
@playwright/test, so webpack pulled playwright-core (node-only: path, chromium-bidi)
into the browser Data-worker bundle and failed to resolve them. Add test/ to every
webpackExclude in this file so the lazy app-module loader never bundles the test tree.
Test specs stay in their canonical location; only the bundler glob is corrected.

* fix(build): exclude test/ from App/Canvas/Task worker lazy-import globs too (#12297)

#12298 fixed only Data.mjs, but the same webpackInclude (/(?:apps|examples|...)/...) + webpackExclude
magic comments live in the App, Canvas (x2), and Task worker realms too — any test spec under an
apps/-matching path could be bundled into those browser worker bundles, pulling node-only deps. Add
test/ to every worker's webpackExclude so no realm bundles the test tree. Verified: build-threads -t
all -n → all worker bundles compiled successfully, 0 chromium-bidi/path/resolve errors. (VDom, Main,
Service workers carry no such magic comments; build scripts none.)

---------

Co-authored-by: tobiu <tobiasuhlig78@gmail.com>"
- 2026-06-01T10:18:34Z @tobiu closed this issue

