Skip to content

Commit

Permalink
Remove tsconfig.build.json files (medplum#3579)
Browse files Browse the repository at this point in the history
* Remove tsconfig.build.json files

* Removed circular depenency

* Fixed react-hooks error
  • Loading branch information
codyebberson authored Dec 19, 2023
1 parent b32e311 commit 9f949c7
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 116 deletions.
2 changes: 1 addition & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"mainEntryPointFilePath": "<projectFolder>/dist/types/index.d.ts",
"bundledPackages": ["@medplum/react-hooks"],
"compiler": {
"tsconfigFilePath": "<projectFolder>/tsconfig.build.json",
"tsconfigFilePath": "<projectFolder>/tsconfig.json",
"skipLibCheck": true
},
"apiReport": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dist"
],
"scripts": {
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs",
"build": "npm run clean && tsc && node esbuild.mjs",
"clean": "rimraf dist",
"medplum": "ts-node src/index.ts",
"test": "jest"
Expand Down
9 changes: 0 additions & 9 deletions packages/cli/tsconfig.build.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"scripts": {
"api-documenter": "api-documenter markdown --input-folder ./dist/api/ --output-folder ./dist/docs/",
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor && npm run api-documenter",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor && npm run api-documenter",
"clean": "rimraf dist",
"test": "jest"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Bot, Bundle, Identifier, Patient, SearchParameter, StructureDefinition } from '@medplum/fhirtypes';
import { MockAsyncClientStorage } from '@medplum/mock';
import { randomUUID, webcrypto } from 'crypto';
import PdfPrinter from 'pdfmake';
import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
Expand All @@ -17,6 +16,7 @@ import {
import { mockFetch } from './client-test-utils';
import { ContentType } from './contenttype';
import { OperationOutcomeError, notFound, unauthorized } from './outcomes';
import { MockAsyncClientStorage } from './storage';
import { getDataType, isDataTypeLoaded, isProfileLoaded } from './typeschema/types';
import { ProfileResource, createReference } from './utils';

Expand Down
33 changes: 33 additions & 0 deletions packages/core/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,36 @@ export class MemoryStorage implements Storage {
return Array.from(this.data.keys())[index];
}
}

/**
* The MockAsyncClientStorage class is a mock implementation of the ClientStorage class.
* This can be used for testing async initialization of the MedplumClient.
*/
export class MockAsyncClientStorage extends ClientStorage implements IClientStorage {
private initialized: boolean;
private initPromise: Promise<void>;
private initResolve: () => void = () => undefined;

constructor() {
super();
this.initialized = false;
this.initPromise = new Promise((resolve) => {
this.initResolve = resolve;
});
}

setInitialized(): void {
if (!this.initialized) {
this.initResolve();
this.initialized = true;
}
}

getInitPromise(): Promise<void> {
return this.initPromise;
}

get isInitialized(): boolean {
return this.initialized;
}
}
9 changes: 0 additions & 9 deletions packages/core/tsconfig.build.json

This file was deleted.

5 changes: 4 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"module": "es2020",
"types": ["jest", "vite/client"],
"lib": ["esnext", "dom"]
"lib": ["esnext", "dom"],
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/expo-polyfills/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
"scripts": {
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor",
"clean": "rimraf ./build",
"test": "jest --runInBand"
},
Expand Down
9 changes: 0 additions & 9 deletions packages/expo-polyfills/tsconfig.build.json

This file was deleted.

5 changes: 4 additions & 1 deletion packages/expo-polyfills/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom"]
"lib": ["esnext", "dom"],
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/fhir-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
],
"scripts": {
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor",
"clean": "rimraf dist",
"test": "jest"
},
Expand Down
9 changes: 0 additions & 9 deletions packages/fhir-router/tsconfig.build.json

This file was deleted.

8 changes: 8 additions & 0 deletions packages/fhir-router/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "es2020",
"types": ["jest", "vite/client"],
"lib": ["esnext", "dom"],
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/hl7/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
],
"scripts": {
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor",
"clean": "rimraf dist",
"test": "jest"
},
Expand Down
9 changes: 0 additions & 9 deletions packages/hl7/tsconfig.build.json

This file was deleted.

8 changes: 8 additions & 0 deletions packages/hl7/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "es2020",
"types": ["jest", "vite/client"],
"lib": ["esnext", "dom"],
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
],
"scripts": {
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor",
"clean": "rimraf dist",
"test": "jest"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/mock/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import {
NewProjectRequest,
NewUserRequest,
OperationOutcomeError,
MockAsyncClientStorage,
} from '@medplum/core';
import { readJson } from '@medplum/definitions';
import { Bundle, CodeableConcept, Patient, SearchParameter, ServiceRequest } from '@medplum/fhirtypes';
import { randomUUID, webcrypto } from 'crypto';
import { TextEncoder } from 'util';
import { MockAsyncClientStorage, MockClient } from './client';
import { MockClient } from './client';
import { DrAliceSmith, DrAliceSmithSchedule, HomerSimpson } from './mocks';

describe('MockClient', () => {
Expand Down
27 changes: 0 additions & 27 deletions packages/mock/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
allOk,
badRequest,
ClientStorage,
ContentType,
getStatus,
IClientStorage,
indexSearchParameter,
loadDataType,
LoginState,
Expand Down Expand Up @@ -570,31 +568,6 @@ export class MockFetchClient {
}
}

export class MockAsyncClientStorage extends ClientStorage implements IClientStorage {
#initialized: boolean;
#initPromise: Promise<void>;
#initResolve: () => void = () => undefined;
constructor() {
super();
this.#initialized = false;
this.#initPromise = new Promise((resolve) => {
this.#initResolve = resolve;
});
}
setInitialized(): void {
if (!this.#initialized) {
this.#initResolve();
this.#initialized = true;
}
}
getInitPromise(): Promise<void> {
return this.#initPromise;
}
get isInitialized(): boolean {
return this.#initialized;
}
}

function base64Encode(str: string): string {
return typeof window !== 'undefined' ? window.btoa(str) : Buffer.from(str).toString('base64');
}
9 changes: 0 additions & 9 deletions packages/mock/tsconfig.build.json

This file was deleted.

6 changes: 6 additions & 0 deletions packages/mock/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "es2020",
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
],
"scripts": {
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor",
"clean": "rimraf dist",
"test": "jest"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDisplayString, MedplumClient, ProfileResource } from '@medplum/core';
import { MockAsyncClientStorage, MockClient } from '@medplum/mock';
import { MedplumClient, MockAsyncClientStorage, ProfileResource, getDisplayString } from '@medplum/core';
import { MockClient } from '@medplum/mock';
import { act, render, screen } from '@testing-library/react';
import { MedplumProvider } from './MedplumProvider';
import { useMedplum, useMedplumContext, useMedplumNavigate, useMedplumProfile } from './MedplumProvider.context';
Expand Down
9 changes: 0 additions & 9 deletions packages/react-hooks/tsconfig.build.json

This file was deleted.

5 changes: 4 additions & 1 deletion packages/react-hooks/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom", "dom.iterable"]
"lib": ["esnext", "dom", "dom.iterable"],
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
],
"scripts": {
"api-extractor": "api-extractor run --local && cp dist/types.d.ts dist/cjs/index.d.ts && cp dist/types.d.ts dist/esm/index.d.ts",
"build": "npm run clean && tsc --project tsconfig.build.json && node esbuild.mjs && npm run api-extractor",
"build": "npm run clean && tsc && node esbuild.mjs && npm run api-extractor",
"clean": "rimraf dist storybook-static",
"dev": "storybook dev -p 6006",
"storybook": "storybook build",
Expand Down
9 changes: 0 additions & 9 deletions packages/react/tsconfig.build.json

This file was deleted.

5 changes: 4 additions & 1 deletion packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"module": "es2020",
"types": ["vite/client"],
"lib": ["esnext", "dom", "dom.iterable"]
"lib": ["esnext", "dom", "dom.iterable"],
"outDir": "dist/types",
"noEmit": false,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}

0 comments on commit 9f949c7

Please sign in to comment.