Commit 7a3603a
authored
chore: remove @openfeature/server-sdk as a runtime dependency (#356)
* Custom EventEmitter
* Bundle type declarations to remove @openfeature devDependencies from .d.ts output
Add dts-bundle-generator to inline all @openfeature/core and
@openfeature/server-sdk types into a single bundled index.d.ts.
This eliminates unresolved import type references in the published
.d.ts files, which previously caused 'Cannot find module' errors for
TypeScript consumers since neither package is declared as a runtime
dependency or peerDependency.
Changes:
- package.json: types field now points to bundled index.d.ts
- package.json: build script runs build:types after tsc builds
- package.json: added dts-bundle-generator to devDependencies
- index.d.ts: generated bundled type declarations (642 lines, zero
@openfeature references, node:diagnostics_channel imported externally)
* Fix yarn install: pin TypeScript to 5.9.3 via resolutions
dts-bundle-generator declares typescript >=5.0.2 as a regular
dependency, causing yarn to resolve TypeScript 7.0.2 for its
nested copy. The built-in compat/typescript patch then fails with
ENOENT trying to lstat an incorrect path. Adding a resolutions
field in the root package.json forces all TypeScript resolutions
to 5.9.3, matching the existing devDependency constraint.
Also includes yarn.lock update for dts-bundle-generator and
devDependencies reordering by yarn.
* Don't export inlined OpenFeature types from bundled declarations
Use --export-referenced-types false so inlined types like Provider,
ResolutionDetails, ServerProviderEvents, ProviderEventEmitter, etc.
are used in DatadogNodeServerProvider's method signatures but not
exported as standalone types. This prevents consumers from
accidentally importing our bundled copy of these types instead of
getting them from their own @openfeature/server-sdk installation.
The bundled index.d.ts now exports only:
- UniversalFlagConfigurationV1
- DatadogNodeServerProviderOptions
- DatadogNodeServerProvider
All OpenFeature types remain inlined (zero @openfeature references)
for SSI compatibility, but are invisible to consumers' import
statements. TypeScript still performs structural comparison when
the customer passes the provider to their own OpenFeature SDK.
* Fix dependency build metadata
* Fix build:types temp file cleanup and add index.d.ts to clean script
- Use trap EXIT in build:types to ensure src/.dts-entry.ts is removed
even if dts-bundle-generator fails
- Add src/.dts-entry.ts to .gitignore as a safety net
- Add index.d.ts to the clean script so all generated artifacts are
removed consistently
* Add prepack guard to prevent @openfeature/server-sdk runtime dependency
Adds a pre-publish script that fails if @openfeature/server-sdk or
@openfeature/core appear in dependencies/peerDependencies, or if
the compiled .js files contain any runtime @openfeature imports.
This prevents accidentally reintroducing the runtime dependency
that would break SSI compatibility with dd-trace-js, where dd-trace
is installed outside the application's node_modules tree and would
get a separate copy of the SDK with a different event emitter
identity.
See DataDog/dd-trace-js#9570 for context.
* Fix duplicate resolutions block in root package.json
The earlier TypeScript resolution was added as a second resolutions
block instead of merging with the existing one, causing yarn to
ignore the typescript@npm:>=5.0.2 pin and crash on TS 7.0.2's
compat patch. Merged into a single resolutions block.
* Add comment explaining why build:types is needed
* formatting
* test: add TypeScript consumer test for node-server package
The node-server package's bundled index.d.ts (generated by
dts-bundle-generator) had no TypeScript consumer test to verify it
compiles correctly from a consumer's perspective. The existing
test-app-node/test.js only tested runtime require() behavior.
This adds:
- test-app-node/tsconfig.json: consumer-style TypeScript config
- test-app-node/typecheck.ts: imports and exercises the public API
(DatadogNodeServerProvider, UniversalFlagConfigurationV1, etc.)
- test-app-node/package.json: adds typescript + @types/node devDeps
- scripts/test-node-package-install.sh: runs tsc --noEmit before
runtime tests
The type check runs in both scenarios:
1. Without @openfeature/* installed (SSI/dd-trace) — verifies the
bundled index.d.ts is self-contained with no dangling references
2. With @openfeature/* installed (normal consumer) — verifies type
compatibility with the real OpenFeature SDK
* test: add tests for NodeProviderEventEmitter
Cover emit/addHandler, handler error isolation (incl. async rejections
and a throwing logger), removeHandler LIFO semantics, removeAllHandlers
scoping, getHandlers, and setLogger chaining/current-logger routing.
* format
* test: verify OpenFeature.setProvider(provider) type-checks against minimum SDK version
Add Test 11 to typecheck.ts that calls OpenFeature.setProvider(provider)
to catch type drift between the bundled index.d.ts and the Provider
interface expected by @openfeature/server-sdk. Uses @ts-ignore on the
import so the file still compiles in the SSI/dd-trace scenario where
@openfeature/server-sdk is not installed.
Add CI step to run the node install test against the minimum supported
OpenFeature SDK versions (server-sdk 1.15.0, core 1.3.0) per
COMPATIBILITY.md, ensuring the type check catches regressions at the
lower bound of the supported range.1 parent 03cf986 commit 7a3603a
17 files changed
Lines changed: 1311 additions & 87 deletions
File tree
- .github/workflows
- packages/node-server
- scripts
- src
- test
- scripts
- test-app-node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
363 | 364 | | |
364 | 365 | | |
365 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 65 | | |
65 | 66 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
0 commit comments