Skip to content

Commit 161653a

Browse files
committed
fix(driver-memory)!: retire the legacy default export that CJS require() could not reach
The package entry's default was a legacy { id, version, onEnable } object, not a kernel plugin, and the CJS build put it on require(...).default while the declarations said export default (attw FalseExportDefault). It leaves the entry; every named export stays. ADR-0087 runtime-export-retired. Claude-Session: https://claude.ai/code/session_017xRBcVyH9FzSkzAGmz8LNE Co-authored-by: Claude <noreply@anthropic.com>
1 parent 65b4920 commit 161653a

4 files changed

Lines changed: 58 additions & 18 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/driver-memory': patch
3+
---
4+
5+
fix(driver-memory)!: retire the legacy `default` export, which a CommonJS `require()` could not reach as its types described
6+
7+
The package entry exported a legacy `{ id, version, onEnable }` object as its `default`. It is not a kernel plugin (the kernel contract is `init` / `start` / `destroy`), and the CommonJS build could only put it on `require('@objectstack/driver-memory').default`, while the published declarations said `export default` (`@arethetypeswrong/cli` reported `FalseExportDefault`). It leaves the published entry. Every named export stays. Nothing in this repository imported the default, and no example, scaffold template, doc page or skill names the package as a string entry of a stack's `plugins` array.
8+
9+
Clause-②: no (narrowing)
10+
Metadata-protocol: none
11+
12+
<!-- adr-0087: not-required (runtime-export-retired @objectstack/driver-memory#default) One runtime object leaves a published package entry; no key of any metadata schema, no object definition and no stored shape is added, removed, renamed or re-shaped, so there is nothing for `objectstack migrate meta` to rewrite and no tombstone. A TypeScript consumer meets the break at its own import, and the line below names the door to use instead. -->
13+
14+
**BREAKING** (a runtime export is removed). It ships as `patch` because the metadata protocol does not move. There is no staged window.
15+
16+
- FROM `default` TO `new DriverPlugin(new InMemoryDriver(), 'memory')` from `@objectstack/runtime`, or `new InMemoryDriver()` handed to whatever registers your drivers.
17+
18+
A stack config that names `'@objectstack/driver-memory'` as a string entry of `plugins` loaded that object and registered an `InMemoryDriver` through it. After this change that entry loads the module without a default and registers no driver, so put `new DriverPlugin(new InMemoryDriver(), 'memory')` in the `plugins` array instead.

‎packages/drivers/driver-memory/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ const driver = new InMemoryDriver({
6161

6262
| Export | Kind | Description |
6363
|:---|:---|:---|
64-
| `default` | legacy plugin object | Legacy `onEnable` shape — not a kernel `Plugin`; register through `DriverPlugin`. |
6564
| `InMemoryDriver` | class | Driver instance for direct use. |
6665
| `InMemoryStrategy` | class | Query execution strategy used by ObjectQL. |
6766
| `FileSystemPersistenceAdapter` | class | Node-only persistence. |
6867
| `LocalStoragePersistenceAdapter` | class | Browser-only persistence. |
6968
| `MemoryAnalyticsService` | class | Adds analytics aggregations backed by memory store. |
7069
| `InMemoryDriverConfig`, `PersistenceAdapterInterface`, `MemoryAnalyticsConfig` | types | Configuration shapes. |
7170

71+
The package has no default export. Register the driver with a named export, as in Quick Start above.
72+
7273
## Configuration
7374

7475
| Option | Type | Default | Notes |
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The package entry carries no `default` export (ADR-0087
5+
* `runtime-export-retired @objectstack/driver-memory#default`).
6+
*
7+
* The retired object was the legacy `{ id, version, onEnable }` shape, which is
8+
* not a kernel `Plugin`, and the CJS build could only reach it as
9+
* `require(...).default` while the published declarations said `export default`
10+
* (attw `FalseExportDefault`). The named exports are the supported surface.
11+
*
12+
* Pinned both ways: the entry has no `default`, and the named door the
13+
* changeset points readers to still constructs a working driver.
14+
*/
15+
16+
import { describe, it, expect } from 'vitest';
17+
import * as entry from './index.js';
18+
19+
describe('driver-memory entry: the legacy default export is retired', () => {
20+
it('the published entry has no default export', () => {
21+
expect('default' in entry).toBe(false);
22+
});
23+
24+
it('the named exports stay, and InMemoryDriver still constructs a driver', () => {
25+
for (const name of ['InMemoryDriver', 'InMemoryStrategy', 'MemoryAnalyticsService', 'FileSystemPersistenceAdapter', 'LocalStoragePersistenceAdapter']) {
26+
expect(typeof (entry as Record<string, unknown>)[name]).toBe('function');
27+
}
28+
const driver = new entry.InMemoryDriver();
29+
expect(driver.name).toBe('com.objectstack.driver.memory');
30+
});
31+
});

‎packages/drivers/driver-memory/src/index.ts‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,10 @@ export type {
6161
UniqueAwareSchema,
6262
} from './memory-unique-constraint.js';
6363

64-
export default {
65-
id: 'com.objectstack.driver.memory',
66-
version: '1.0.0',
67-
68-
onEnable: async (context: any) => {
69-
const { logger, config, drivers } = context;
70-
logger.info('[Memory Driver] Initializing...');
71-
72-
if (drivers) {
73-
const driver = new InMemoryDriver(config);
74-
drivers.register(driver);
75-
logger.info(`[Memory Driver] Registered driver: ${driver.name}`);
76-
} else {
77-
logger.warn('[Memory Driver] No driver registry found in context.');
78-
}
79-
}
80-
};
64+
// [ADR-0087 runtime-export-retired] This entry has NO default export, on
65+
// purpose. The legacy `{ id, version, onEnable }` object it once carried was not
66+
// a kernel `Plugin` (the contract is init/start/destroy), and the package's CJS
67+
// build could only place it on `require(...).default`, which the published
68+
// `.d.ts` misdescribed (attw `FalseExportDefault`). Register this driver through
69+
// a named export: `new DriverPlugin(new InMemoryDriver(), 'memory')`
70+
// (`@objectstack/runtime`), or construct `InMemoryDriver` directly.

0 commit comments

Comments
 (0)