> Superseded by dev-5.66.5: demos now use official RequireJS 2.3.6 instead of the local mini loader. This document is retained only as development history.

# UnifiedWriter dev-5.66.4 - AMD parallel initialization fix

## Issue

After adopting UnifiedControl, `demo/basic.html` could fail with:

```text
TypeError: Class extends value undefined is not a constructor or null
    at WorkbenchControl.js:17
```

`EditorControl.js` itself returned a valid `EditorControl` class, but `WorkbenchControl.js` still received `undefined` for its `./EditorControl` dependency.

## Cause

The demo uses a small RequireJS-like loader in `scripts/vendor/require.js`. When two dependency branches request the same module at the same time, the loader marked the module as `initializing` and immediately returned the current `module.exports`. For factory-return AMD modules, `module.exports` is still `undefined` until the factory finishes.

The dependency graph made this visible:

```text
UnifiedWriter/main -> EditorControl
UnifiedWriter/main -> WorkbenchControl -> EditorControl
```

`WorkbenchControl` could therefore receive `undefined` even though `EditorControl.js` later completed and returned the class.

## Fix

`require.js` now queues callbacks for modules that are already initializing and flushes those callbacks after the factory returns the final export.

This matches expected AMD behavior more closely and prevents `class WorkbenchControl extends EditorControl` from evaluating with an incomplete dependency.

## Scope

This fix is limited to the demo AMD loader. UnifiedWriter source remains non-bundled AMD, and UnifiedControl continues to be referenced as an external peer package.
