Skip to content

Commit

Permalink
build(drivers/framework): Fix type generation for ESM and add exports…
Browse files Browse the repository at this point in the history
… field (#18824)

This PR updates the majority of packages in packages/drivers and
packages/framework to generate proper types in ESM builds and adds an
`exports` field. The packages were already building using
moduleResolution: node16 by virtue of inheriting from the new shared
configs, so no changes were needed there. They also have a test using
arethetypeswrong that runs in CI.

I did NOT add an exports field to the odsp-driver package, because doing
that right now breaks a lot of downstream compilation. We should be able
to resolve that once more/all packages are using node16 module
resolution.
  • Loading branch information
tylerbutler committed Dec 14, 2023
1 parent c4939c7 commit 7c00183
Show file tree
Hide file tree
Showing 33 changed files with 436 additions and 21 deletions.
14 changes: 14 additions & 0 deletions packages/drivers/debugger/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -22,6 +34,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
"ci:build:docs": "api-extractor run",
Expand Down Expand Up @@ -57,6 +70,7 @@
"copyfiles": "^2.4.1",
"eslint": "~8.50.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/driver-base/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -24,6 +36,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -93,6 +106,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"socket.io-client": "^4.6.1",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/driver-web-cache/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -24,6 +36,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -64,6 +77,7 @@
"fake-indexeddb": "3.1.4",
"jest": "^29.6.2",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/fluidapp-odsp-urlResolver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -69,6 +82,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/local-driver/package.json
Expand Up @@ -10,6 +10,18 @@
},
"license": "MIT",
"author": "Microsoft and contributors",
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"browser": {
Expand All @@ -25,6 +37,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -107,6 +120,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"socket.io-client": "^4.6.1",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/odsp-driver-definitions/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -55,6 +68,7 @@
"cross-env": "^7.0.3",
"eslint": "~8.50.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
2 changes: 2 additions & 0 deletions packages/drivers/odsp-driver/package.json
Expand Up @@ -24,6 +24,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -102,6 +103,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"sinon": "^7.4.2",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/odsp-urlResolver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -67,6 +80,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/replay-driver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -22,6 +34,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
"ci:build:docs": "api-extractor run",
Expand Down Expand Up @@ -60,6 +73,7 @@
"eslint": "~8.50.0",
"nock": "^13.3.3",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/routerlicious-driver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -24,6 +36,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -108,6 +121,7 @@
"moment": "^2.21.0",
"nock": "^13.3.3",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"sinon": "^7.4.2",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/routerlicious-urlResolver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -71,6 +84,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down

0 comments on commit 7c00183

Please sign in to comment.