Skip to content

Commit f451e25

Browse files
authored
fix: correct rollup to bundle all but core (#846)
My rollup config was invalid, but clumsily working until a recent change in how we defined the event emitter type. The impact was the the bundled types for the web imported `from 'events'` instead of bundling it. This PR fixes the mis-configuration (see comments). Here is a screenshot showing the bundled types in the dist now (notice the import is gone and the emitter is in-lined, no other changes are present): ![image](https://github.com/open-feature/js-sdk/assets/25272906/8728911d-7c72-4d53-8dc2-d748837a616e) In server, this type is available from node, so we DON'T need to bundle it, and in fact, SHOULD import it. This is easily done by importing it like `from 'node:events'`. I don't think it would be a problem if we bundled it anyway, but this is more correct. Fixes: #845 Signed-off-by: Todd Baert <[email protected]>
1 parent b1abef1 commit f451e25

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

packages/client/src/events/open-feature-event-emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GenericEventEmitter } from '@openfeature/core';
2-
import EventEmitter from 'events';
2+
import { EventEmitter } from 'events';
33
import { ProviderEmittableEvents } from './events';
44
/**
55
* The OpenFeatureEventEmitter can be used by provider developers to emit

packages/server/src/events/open-feature-event-emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GenericEventEmitter } from '@openfeature/core';
2-
import EventEmitter from 'events';
2+
import { EventEmitter } from 'node:events';
33
import { ProviderEvents } from './events';
44

55
/**

rollup.config.mjs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ export default {
77
input: "./src/index.ts",
88
output: {
99
file: './dist/types.d.ts',
10-
format: 'es', // module format doesn't really matter here since output i
10+
format: 'es', // module format doesn't really matter here since output is types
11+
},
12+
// function indicating which deps should be considered external: external deps will NOT have their types bundled
13+
external: (id) => {
14+
// bundle everything but '@openfeature/core', which is a peer
15+
return id === '@openfeature/core';
1116
},
12-
external: [
13-
// function indicating which deps should be considered external: non-external deps will have their types bundled
14-
(id) => {
15-
// bundle 'events' types
16-
return id !== 'events';
17-
}
18-
],
1917
plugins: [
2018
// use the rollup override tsconfig (applies equivalent in each sub-packages as well)
21-
dts({tsconfig: './tsconfig.rollup.json'}),
19+
dts({tsconfig: './tsconfig.rollup.json', respectExternal: true }),
2220
],
2321
};

0 commit comments

Comments
 (0)