Skip to content

Commit

Permalink
build(client): Use new node16 tsconfigs in azure, client, and DDS pro…
Browse files Browse the repository at this point in the history
…jects (#18152)

This PR is the first in several that will update the CommonJS builds
within the repo to use `module: node16`, which implies
`moduleResolution: node16`.

There are new configs in the build-common package, and these configs are
used as follows:

```json
"extends": [
	"../../../../../common/build/build-common/tsconfig.base.json",
	"../../../../../common/build/build-common/tsconfig.cjs.json",
],
```

These configs are designed to be used together using [TypeScript's
support for extending multiple config
files](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#supporting-multiple-configuration-files-in-extends).

- tsconfig.base.json - This base config contains defaults that all
packages within the repo should use as a baseline.
- tsconfig.cjs.json - This config sets `module: Node16` and is intended
for CommonJS builds. This config is intended to
  be layered on top of the base config.
- tsconfig.esm.json - This config sets `module: ESNext` and
`moduleResolution: Node10` and is intended for ESM builds. This config
is intended to be layered on top of the base config. This config uses
Node10 module resolution because Node16 cannot be used to build both CJS
and ESM from a common source.
- tsconfig.test.json - This config disables some settings that we don't
want to use in test code, like `declaration` and `decarationMap`. It
also enables the `node` types by default.

This PR updates the packages in the packages/common and packages/dds
paths. For each package, the CJS, ESM, and test tsconfig files are
updated to use the new build-common configs, which means that CJS builds
now use module: node16 which implies moduleResolution: node16. ESNext
builds continue to use Node10 module resolution because Node16 cannot be
used to build both CJS and ESM from a common source.
  • Loading branch information
tylerbutler committed Nov 8, 2023
1 parent 52652b8 commit de14e47
Show file tree
Hide file tree
Showing 70 changed files with 373 additions and 314 deletions.
17 changes: 9 additions & 8 deletions azure/packages/azure-client/src/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "../../dist/test",
"composite": true,
"types": ["mocha", "node"],
"skipLibCheck": true,
},
"extends": [
"../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"references": [
{
"path": "../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../dist/test",
"types": ["mocha", "node"],
},
}
3 changes: 1 addition & 2 deletions azure/packages/azure-client/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"extends": ["./tsconfig.json", "../../../common/build/build-common/tsconfig.esm.json"],
"compilerOptions": {
"outDir": "./lib",
"module": "esnext",
},
}
11 changes: 6 additions & 5 deletions azure/packages/azure-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"extends": [
"../../../common/build/build-common/tsconfig.base.json",
"../../../common/build/build-common/tsconfig.cjs.json",
],
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"composite": true,
"types": ["node"],
},
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
}
10 changes: 6 additions & 4 deletions azure/packages/azure-local-service/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"exclude": [],
"extends": [
"../../../common/build/build-common/tsconfig.base.json",
"../../../common/build/build-common/tsconfig.cjs.json",
],
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"composite": true,
},
"include": ["src/**/*"],
}
19 changes: 10 additions & 9 deletions azure/packages/azure-service-utils/src/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "../../dist/test",
"declaration": false,
"declarationMap": false,
"skipLibCheck": true,
"noEmit": true,
},
"extends": [
"../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"references": [
{
"path": "../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../dist/test",
"noEmit": true,
"types": [],
},
}
3 changes: 1 addition & 2 deletions azure/packages/azure-service-utils/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"extends": ["./tsconfig.json", "../../../common/build/build-common/tsconfig.esm.json"],
"compilerOptions": {
"outDir": "./lib",
"module": "esnext",
},
}
9 changes: 5 additions & 4 deletions azure/packages/azure-service-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"extends": [
"../../../common/build/build-common/tsconfig.base.json",
"../../../common/build/build-common/tsconfig.cjs.json",
],
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
"compilerOptions": {
"strictNullChecks": true,
"rootDir": "./src",
"outDir": "./dist",
"composite": true,
},
"include": ["src/**/*"],
}
21 changes: 21 additions & 0 deletions common/build/build-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,24 @@ It can be extended in your package's local configuration file like the following

This package previously exported a series of configurations with differing levels of validation.
These configurations are now deprecated and have been replaced with the configuration noted above.

## TypeScript Configurations (`tsconfig.json`)

This package includes several TypeScript config (tsconfig) files that are contain the common configurations used within
the Fluid Framework repo. These configs are designed to be used together using [TypeScript's support for extending
multiple config
files](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#supporting-multiple-configuration-files-in-extends).

- tsconfig.base.json - This base config contains defaults that all packages within the repo should use as a baseline.
- tsconfig.cjs.json - This config sets `module: Node16` and is intended for CommonJS builds. This config is intended to
be layered on top of the base config.
- tsconfig.esm.json - This config sets `module: ESNext` and `moduleResolution: Node10` and is intended for ESM builds. This config
intended to be layered on top of the base config. This config uses Node10 module resolution because Node16 cannot be
used to build both CJS and ESM from a common source.
- tsconfig.test.json - This config disables some settings that we don't want to use in test code, like `declaration` and
`decarationMap`. It also enables the `node` types by default.

### Legacy tsconfig

This package also contains a legacy base tsconfig, `ts-common-config.json`. This config is still used in some places
within the repo but is considered deprecated.
1 change: 1 addition & 0 deletions common/build/build-common/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"esModuleInterop": true,
"incremental": true,
"inlineSources": true,
"jsx": "react",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"noImplicitAny": false,
"noUnusedLocals": true,
Expand Down
1 change: 0 additions & 1 deletion common/build/build-common/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": ["./tsconfig.base.json"],
"compilerOptions": {
"module": "Node16",
},
Expand Down
1 change: 0 additions & 1 deletion common/build/build-common/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": ["./tsconfig.base.json"],
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node10",
Expand Down
3 changes: 2 additions & 1 deletion common/build/build-common/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"extends": ["./tsconfig.esm.json"],
"extends": ["./tsconfig.base.json", "./tsconfig.esm.json"],
"compilerOptions": {
"composite": false,
"types": ["node"],
"declaration": false,
"declarationMap": false,
"skipLibCheck": true,
"module": "CommonJS",
},
}
2 changes: 1 addition & 1 deletion packages/common/client-utils/src/hashFileBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function hashFile(
if (crypto.subtle === undefined) {
return import(
/* webpackChunkName: "FluidFramework-HashFallback" */
"./hashFileNode"
"./hashFileNode.js"
).then(async (m) => m.hashFile(file, algorithm, hashEncoding));
}

Expand Down
15 changes: 9 additions & 6 deletions packages/common/client-utils/src/test/jest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/jest",
"types": ["jest", "jest-environment-puppeteer", "node", "puppeteer"],
},
"extends": [
"../../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"references": [
{
"path": "../../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/jest",
"types": ["jest", "jest-environment-puppeteer", "node", "puppeteer"],
},
}
16 changes: 9 additions & 7 deletions packages/common/client-utils/src/test/mocha/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/mocha",
"types": ["node", "mocha"],
},
"extends": [
"../../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"references": [
{
"path": "../../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/mocha",
"types": ["mocha", "node"],
},
}
28 changes: 15 additions & 13 deletions packages/common/client-utils/src/test/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"extends": [
"../../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"exclude": [
"dist",
"node_modules"
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/types",
},
"include": [
"./**/*"
],
"references": [
{
"path": "../../.."
}
]
"references": [
{
"path": "../../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/types",
"types": [],
},
}
3 changes: 1 addition & 2 deletions packages/common/client-utils/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"extends": ["./tsconfig.json", "../../../common/build/build-common/tsconfig.esm.json"],
"compilerOptions": {
"outDir": "./lib",
"module": "esnext",
},
}
10 changes: 6 additions & 4 deletions packages/common/client-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"extends": [
"../../../common/build/build-common/tsconfig.base.json",
"../../../common/build/build-common/tsconfig.cjs.json",
],
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"composite": true,
"baseUrl": ".",
"paths": {
"perf_hooks": ["types/perf_hooks.d.ts"],
},
"types": ["events"],
},
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
}
33 changes: 16 additions & 17 deletions packages/common/container-definitions/src/test/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/types",
"declaration": false,
"declarationMap": false,
"skipLibCheck": true,
"noEmit": true,
},
"include": [
"./**/*"
],
"references": [
{
"path": "../../.."
}
]
"extends": [
"../../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"references": [
{
"path": "../../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../../dist/test/types",
"noEmit": true,
"types": [],
},
}
3 changes: 1 addition & 2 deletions packages/common/container-definitions/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"extends": ["./tsconfig.json", "../../../common/build/build-common/tsconfig.esm.json"],
"compilerOptions": {
"outDir": "./lib",
"module": "esnext",
},
}
8 changes: 5 additions & 3 deletions packages/common/container-definitions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"extends": [
"../../../common/build/build-common/tsconfig.base.json",
"../../../common/build/build-common/tsconfig.cjs.json",
],
"include": ["src/**/*"],
"exclude": ["src/test/**/*"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"composite": true,
},
"include": ["src/**/*"],
}
17 changes: 8 additions & 9 deletions packages/common/core-interfaces/src/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"extends": "@fluidframework/build-common/ts-common-config.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "../../dist/test",
"declaration": false,
"declarationMap": false,
"skipLibCheck": true,
"noEmit": true,
},
"extends": [
"../../../../../common/build/build-common/tsconfig.base.json",
"../../../../../common/build/build-common/tsconfig.test.json",
],
"include": ["./**/*"],
"references": [
{
"path": "../..",
},
],
"compilerOptions": {
"rootDir": "./",
"outDir": "../../dist/test",
},
}
Loading

0 comments on commit de14e47

Please sign in to comment.