Skip to content

Commit

Permalink
fix: removed duped core types (#800)
Browse files Browse the repository at this point in the history
A while back I added:

```json
    "paths": {
      "@openfeature/core": [ "./packages/shared/src" ]
    },      
```

To the tsconfigs, which helped with local dev by always resolving
`src/*` files from sibling packages instead of anything in their
`dist/`.

It also had the nasty side-effect of causing our type bundling to
include types from this package in it's output, causing duplicated
artifacts and possible compiler issues. I've overridden this with a
custom `tsconfig.rollup.json`.

Before this fix, the web/server SDK dists contained dupes of the stuff
in shared:

```ts
import EventEmitter from 'events';

type FlagValueType = 'boolean' | 'string' | 'number' | 'object';
type PrimitiveValue = null | boolean | string | number;
type JsonObject = {
    [key: string]: JsonValue;
};
type JsonArray = JsonValue[];
/**
 * Represents a JSON node value.
 */
```

After this fix, they import them:

```ts
import { BaseHook, HookHints, EvaluationDetails, JsonValue, EvaluationLifeCycle, ManageLogger, Eventing, ClientMetadata, ProviderStatus, ClientProviderEvents, GenericEventEmitter, CommonEventDetails, FlagValue, CommonProvider, EvaluationContext, Logger, ResolutionDetails, EventHandler, OpenFeatureCommonAPI, ManageContext } from '@openfeature/core';
export * from '@openfeature/core';
```

---------

Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert authored Jan 31, 2024
1 parent 4114e63 commit 7cc1e09
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 39 deletions.
37 changes: 2 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"devDependencies": {
"@openfeature/flagd-provider": "^0.10.2",
"@openfeature/flagd-web-provider": "^0.4.0",
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/events": "^3.0.0",
"@types/jest": "^29.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/client/tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {}
}
}
6 changes: 6 additions & 0 deletions packages/nest/tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {}
}
}
6 changes: 6 additions & 0 deletions packages/react/tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {}
}
}
6 changes: 6 additions & 0 deletions packages/server/tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {}
}
}
6 changes: 6 additions & 0 deletions packages/shared/tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {}
}
}
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// this config rolls up all the types in the project to a single declaration (d.ts) file.
// we do NOT use rollup to build (we use esbuild for that)

import alias from '@rollup/plugin-alias';
import dts from 'rollup-plugin-dts';

export default {
Expand All @@ -18,6 +17,7 @@ export default {
}
],
plugins: [
dts({tsconfig: './tsconfig.json'}),
// use the rollup override tsconfig (applies equivalent in each sub-packages as well)
dts({tsconfig: './tsconfig.rollup.json'}),
],
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"@openfeature/core": [ "./packages/shared/src" ]
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {}
}
}

0 comments on commit 7cc1e09

Please sign in to comment.