optimade
Version:
Aggregating Optimade client for the online materials databases
56 lines (36 loc) • 3.38 kB
Markdown
## ADDED Requirements
### Requirement: Build step produces both bundle outputs
The `prepublishOnly` build pipeline SHALL transform TypeScript sources and emit both `dist/index.mjs` (ES module) and `dist/index.js` (UMD) with exit code 0. The rollup TypeScript plugin's `transform` hook SHALL be invoked for every `.ts` entry under `src/`, so that native acorn parsing never sees raw TypeScript syntax.
#### Scenario: Rollup build succeeds on Node 18+
- **WHEN** `npm run build` is executed on Node 18+
- **THEN** the command exits with code 0
- **AND** the file `dist/index.mjs` exists and is non-empty
- **AND** the file `dist/index.js` exists, is non-empty, and contains a UMD wrapper
#### Scenario: TypeScript transform hook is engaged
- **WHEN** `rollup --config` runs against `src/index.ts`
- **THEN** the `rollup-plugin-typescript2` `transform` hook returns transformed JavaScript (not `undefined`) for `src/index.ts`
- **AND** no `Unexpected token ... you need plugins to import files that are not JavaScript` error is raised
### Requirement: Prefetch step does not crash on modern Node
The `prefetch` script (`node prefetch.js`) SHALL run to completion without an uncaught `TypeError` originating from `AbortController`/`AbortSignal`. It SHALL rely on the native global `AbortController` provided by Node 18+ and SHALL NOT install a polyfill override that is incompatible with undici's internal `fetch` implementation.
#### Scenario: AbortSignal timeout no longer throws removeEventListener
- **WHEN** `node prefetch.js` runs on Node 18+ and a provider request times out
- **THEN** the timeout is handled via the native `AbortController`
- **AND** no `TypeError: this.removeEventListener is not a function` is thrown
- **AND** the process does not exit with a non-zero code due to the abort path
#### Scenario: Transient provider errors remain non-fatal
- **WHEN** a provider returns non-JSON (e.g. an HTML error page) or a network error
- **THEN** the error is caught by the existing `try/catch` blocks in `src/index.ts`
- **AND** `prefetch.js` continues processing remaining providers rather than crashing
### Requirement: Publish pipeline end-to-end
`npm publish` SHALL drive `prepublishOnly` (`npm run build && npm run prefetch`) to completion with exit code 0 on Node 18+, so that the package can be released without a non-zero exit from the lifecycle hook.
#### Scenario: Dry-run publish completes
- **WHEN** `npm publish --dry-run` is executed on Node 18+
- **THEN** `prepublishOnly` runs both `build` and `prefetch`
- **AND** neither step terminates the publish with a non-zero exit code attributable to a dependency incompatibility
### Requirement: Dependency declarations reflect the fix
`package.json` SHALL declare `rollup-plugin-typescript2` at `^0.37.0` (or higher) in `devDependencies` and SHALL NOT list `node-abort-controller` in `dependencies`. The runtime code SHALL continue to reference the global `AbortController` (no source change required in `src/utils.ts`).
#### Scenario: Dependency manifest after the change
- **WHEN** `package.json` is inspected after the change is applied
- **THEN** `devDependencies.rollup-plugin-typescript2` is `^0.37.0` or greater
- **AND** `dependencies` does not contain an entry for `node-abort-controller`
- **AND** `src/utils.ts` still constructs `new AbortController()` from the global scope